// xestiaab_contactload.h - Xestia Address Book Contact Load Unit Tests.
//
-// (c) 2012-2015 Xestia Software Development.
+// (c) 2012-2017 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
#include <gtest/gtest.h>
-#include "../contacteditor/ContactDataObject.h"
+#include "../contacteditor/cdo/ContactDataObject.h"
-TEST(ContactLoad, ContactLoadTests){
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithMissingFileThenReturnFileMissingError)
+{
- ContactDataObject TestFile;
+ // Given
- // Check that the file given is not missing.
+ ContactDataObject testFile;
- ASSERT_EQ(CONTACTLOAD_FILEMISSING, TestFile.LoadFile("MissingFile.vcf"));
+ // When
+
+ ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+ testFileLoadStatus = testFile.LoadFile("MissingFile.vcf");
- // Check that the file given does not have an error when attempting to
- // open it.
+ // Then
+
+ ASSERT_EQ(CONTACTLOAD_FILEMISSING, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithInvalidPermissionsSetThenReturnInvalidPermissionsError)
+{
+
+ // Given
- ASSERT_EQ(CONTACTLOAD_FILEERROR, TestFile.LoadFile("InvalidPermissions.vcf"));
+ ContactDataObject testFile;
- // Check that the file is a valid vCard 4.0 file.
+ // When
+
+ ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+ testFileLoadStatus = testFile.LoadFile("InvalidPermissions.vcf");
- ASSERT_EQ(CONTACTLOAD_FILEINVALIDFORMAT, TestFile.LoadFile("LoadCheck-Load1-v3.vcf"));
+ // Then
+
+ ASSERT_EQ(CONTACTLOAD_FILEERROR, testFileLoadStatus);
- // Check that the vCard 4.0 file meets the base specification.
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithInvalidFormatThenReturnInvalidFormatError)
+{
+
+ // Given
+
+ ContactDataObject testFile;
- ASSERT_EQ(CONTACTLOAD_FILEBASESPECFAIL, TestFile.LoadFile("LoadCheck-Load3.vcf"));
+ // When
- // Check that the vCard 4.0 file loads OK.
+ ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+ testFileLoadStatus = testFile.LoadFile("LoadCheck-Load1-v3.vcf");
+
+ // Then
- ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+ ASSERT_EQ(CONTACTLOAD_FILEINVALIDFORMAT, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithNonMeetingBaseSpecificationThenReturnFileBaseSpecificationError)
+{
+
+ // Given
+
+ ContactDataObject testFile;
+
+ // When
+
+ ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+ testFileLoadStatus = testFile.LoadFile("LoadCheck-Load3.vcf");
+
+ // Then
+
+ ASSERT_EQ(CONTACTLOAD_FILEBASESPECFAIL, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledThenContactLoadedOK)
+{
+
+ // Given
+
+ ContactDataObject testFile;
+
+ // When
+
+ ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+ testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ // Then
+
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenLoadedContactDataObjectWhenContactKindIsCheckedThenContactKindIsIndividual)
+{
+
+ // Check that the kind status has been set. (KIND).
+
+ // Given
+
+ ContactDataObject testFile;
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ ContactKindType testFileContactKindStatus = testFile.ContactKind;
+
+ // Then
// Check that the kind status has been set. (KIND).
- ASSERT_NE(CONTACTKIND_NONE, TestFile.ContactKind);
- ASSERT_EQ(CONTACTKIND_INDIVIDUAL, TestFile.ContactKind);
+ ASSERT_NE(CONTACTKIND_NONE, testFileContactKindStatus);
+ ASSERT_EQ(CONTACTKIND_INDIVIDUAL, testFileContactKindStatus);
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnGroupsListForFirstGroupThenOnlyFirstGroupIsReturned)
+{
+
// Check that the groups have been read (MEMBER).
+
+ std::map<int,wxString>::iterator testFileIter;
+
+ // Given
+
+ ContactDataObject testFile;
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- std::map<int,wxString>::iterator TestFileIter;
- std::map<int,int>::iterator TestFileIntIter;
+ // When
+
+ testFileIter = testFile.GroupsList.find(0);
- TestFileIter = TestFile.GroupsList.find(0);
+ // Then
- ASSERT_NE(TestFile.GroupsList.end(), TestFileIter);
- ASSERT_EQ("7a2af44d-6431-4797-a55f-d86d56304fda", TestFileIter->second);
+ ASSERT_NE(testFile.GroupsList.end(), testFileIter);
+ ASSERT_EQ("7a2af44d-6431-4797-a55f-d86d56304fda", testFileIter->second);
- // Check the ALTID parameter.
+}
- TestFileIter = TestFile.GroupsListAltID.find(0);
- ASSERT_NE(TestFile.GroupsListAltID.end(), TestFileIter);
- ASSERT_EQ("35", TestFileIter->second);
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnGroupsListAltIDForFirstGroupThenOnlyFirstGroupAltIDIsReturned)
+{
- // Check the PID parameter.
+ // Check the ALTID parameter for MEMBER.
+
+ std::map<int,wxString>::iterator testFileIter;
+
+ // Given
- TestFileIter = TestFile.GroupsListPID.find(0);
- ASSERT_NE(TestFile.GroupsListPID.end(), TestFileIter);
- ASSERT_EQ("40", TestFileIter->second);
+ ContactDataObject testFile;
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- // Check the PREF parameter.
+ // When
+
+ testFileIter = testFile.GroupsListAltID.find(0);
+
+ // Then
+
+ ASSERT_NE(testFile.GroupsListAltID.end(), testFileIter);
+ ASSERT_EQ("35", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnGroupsListPIDForFirstGroupThenOnlyFirstGroupPIDIsReturned)
+{
+
+ // Check the PID parameter for MEMBER.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
- TestFileIntIter = TestFile.GroupsListPref.find(0);
- ASSERT_NE(TestFile.GroupsListPref.end(), TestFileIntIter);
- ASSERT_EQ(45, TestFileIntIter->second);
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- // Check the MEDIATYPE parameter.
+ // When
+
+ testFileIter = testFile.GroupsListPID.find(0);
- TestFileIter = TestFile.GroupsListMediaType.find(0);
- ASSERT_NE(TestFile.GroupsListMediaType.end(), TestFileIter);
- ASSERT_EQ("text/plain", TestFileIter->second);
+ // Then
+
+ ASSERT_NE(testFile.GroupsListPID.end(), testFileIter);
+ ASSERT_EQ("40", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnGroupsListPreferenceForFirstGroupThenOnlyFirstGroupPreferenceIsReturned)
+{
+
+ // Check the PREF parameter for MEMBER.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- // Check the extra tokens parameter.
+ // When
+
+ testFileIntIter = testFile.GroupsListPref.find(0);
- TestFileIter = TestFile.GroupsListTokens.find(0);
- ASSERT_NE(TestFile.GroupsListTokens.end(), TestFileIter);
- ASSERT_EQ("EXAMPLE=Meep", TestFileIter->second);
+ // Then
+
+ ASSERT_NE(testFile.GroupsListPref.end(), testFileIntIter);
+ ASSERT_EQ(45, testFileIntIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnGroupsListMediatypeForFirstGroupThenOnlyFirstGroupMediatypeIsReturned)
+{
+
+ // Check the MEDIATYPE parameter for MEMBER.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+ testFileIter = testFile.GroupsListMediaType.find(0);
+
+ // Then
+
+ ASSERT_NE(testFile.GroupsListMediaType.end(), testFileIter);
+ ASSERT_EQ("text/plain", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnGroupsListExtraTokensForFirstGroupThenOnlyFirstGroupExtraTokensIsReturned)
+{
+
+ // Check the extra tokens parameter for MEMBER.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ testFileIter = testFile.GroupsListTokens.find(0);
+
+ // Then
+
+ ASSERT_NE(testFile.GroupsListTokens.end(), testFileIter);
+ ASSERT_EQ("EXAMPLE=Meep", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnFullNameForFirstFullNameThenOnlyFirstFullNameIsReturned)
+{
+
// Check that the formatted name has been read (FN).
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- TestFileIter = TestFile.FullNamesList.find(0);
- ASSERT_NE(TestFile.FullNamesList.end(), TestFileIter);
- ASSERT_EQ("Test Contact", TestFileIter->second);
+ // When
- // Check the TYPE parameter.
+ testFileIter = testFile.FullNamesList.find(0);
- TestFileIter = TestFile.FullNamesListType.find(0);
- ASSERT_NE(TestFile.FullNamesListType.end(), TestFileIter);
- ASSERT_EQ("work", TestFileIter->second);
+ // Then
+
+ ASSERT_NE(testFile.FullNamesList.end(), testFileIter);
+ ASSERT_EQ("Test Contact", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnFullNameTypeForFirstFullNameThenOnlyFirstFullNameTypeIsReturned)
+{
+
+ // Check the TYPE parameter for FN.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ testFileIter = testFile.FullNamesListType.find(0);
+
+ // Then
+
+ ASSERT_NE(testFile.FullNamesListType.end(), testFileIter);
+ ASSERT_EQ("work", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnFullNameLanguageForFirstFullNameThenOnlyFirstFullNameLanguageIsReturned)
+{
+
+ // Check the LANGUAGE parameter for FN.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- // Check the LANGUAGE parameter.
+ // When
+
+ testFileIter = testFile.FullNamesListLanguage.find(0);
+
+ // Then
+
+ ASSERT_NE(testFile.FullNamesListLanguage.end(), testFileIter);
+ ASSERT_EQ("kw", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnFullNameAltIDForFirstFullNameThenOnlyFirstFullNameAltIDIsReturned)
+{
+
+ // Check the ALTID parameter for FN.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- TestFileIter = TestFile.FullNamesListLanguage.find(0);
- ASSERT_NE(TestFile.FullNamesListLanguage.end(), TestFileIter);
- ASSERT_EQ("kw", TestFileIter->second);
+ // When
- // Check the ALTID parameter.
+ testFileIter = testFile.FullNamesListAltID.find(0);
+
+ // Then
- TestFileIter = TestFile.FullNamesListAltID.find(0);
- ASSERT_NE(TestFile.FullNamesListAltID.end(), TestFileIter);
- ASSERT_EQ("500", TestFileIter->second);
+ ASSERT_NE(testFile.FullNamesListAltID.end(), testFileIter);
+ ASSERT_EQ("500", testFileIter->second);
- // Check the PID parameter.
+}
- TestFileIter = TestFile.FullNamesListPID.find(0);
- ASSERT_NE(TestFile.FullNamesListPID.end(), TestFileIter);
- ASSERT_EQ("40", TestFileIter->second);
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnFullNamePIDForFirstFullNameThenOnlyFirstFullNamePIDIsReturned)
+{
+
+ // Check the PID parameter for FN.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- // Check the PREF parameter.
+ // When
- TestFileIntIter = TestFile.FullNamesListPref.find(0);
- ASSERT_NE(TestFile.FullNamesListPref.end(), TestFileIntIter);
- ASSERT_EQ(45, TestFileIntIter->second);
+ testFileIter = testFile.FullNamesListPID.find(0);
+
+ // Then
+
+ ASSERT_NE(testFile.FullNamesListPID.end(), testFileIter);
+ ASSERT_EQ("40", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnFullNamePrefForFirstFullNameThenOnlyFirstFullNamePrefIsReturned)
+{
+
+ // Check the PREF parameter for FN.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- // Check for the extra tokens parameter.
+ // When
+
+ testFileIntIter = testFile.FullNamesListPref.find(0);
- TestFileIter = TestFile.FullNamesListTokens.find(0);
- ASSERT_NE(TestFile.FullNamesListTokens.end(), TestFileIter);
- ASSERT_EQ("EXAMPLE=Baaa", TestFileIter->second);
+ // Then
+
+ ASSERT_NE(testFile.FullNamesListPref.end(), testFileIntIter);
+ ASSERT_EQ(45, testFileIntIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenFindIsCalledOnFullNameExtraTokensForFirstFullNameThenOnlyFirstFullNameExtraTokensIsReturned)
+{
+
+ // Check for the extra tokens parameter for FN.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- // Check that the name has been read (N).
+ // When
- ASSERT_EQ("Contact", TestFile.NameSurname);
- ASSERT_EQ("Test", TestFile.NameForename);
- ASSERT_EQ("Example", TestFile.NameOtherNames);
- ASSERT_EQ("Robot", TestFile.NameTitle);
- ASSERT_EQ("LOONY", TestFile.NameSuffix);
+ testFileIter = testFile.FullNamesListTokens.find(0);
- // Check the ALTID parameter.
+ // Then
+
+ ASSERT_NE(testFile.FullNamesListTokens.end(), testFileIter);
+ ASSERT_EQ("EXAMPLE=Baaa", testFileIter->second);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenNameValuesAreRetrievedThenValuesForNameIsReturned)
+{
+
+ // Check that the name has been read for N.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ wxString nameSurname = testFile.NameSurname;
+ wxString nameForename = testFile.NameForename;
+ wxString nameOtherNames = testFile.NameOtherNames;
+ wxString nameTitle = testFile.NameTitle;
+ wxString nameSuffix = testFile.NameSuffix;
+
+ // Then
+
+ ASSERT_EQ("Contact", nameSurname);
+ ASSERT_EQ("Test", nameForename);
+ ASSERT_EQ("Example", nameOtherNames);
+ ASSERT_EQ("Robot", nameTitle);
+ ASSERT_EQ("LOONY", nameSuffix);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenNameAltIDIsRetrievedThenValueforNameAltIDIsReturned)
+{
+
+ // Check the ALTID parameter for N.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ wxString nameAltID = testFile.NameAltID;
+
+ // Then
+
+ ASSERT_EQ("3", nameAltID);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenNameLanguageIsRetrievedThenValueforNameLanguageIsReturned)
+{
+
+ // Check the LANGUAGE parameter for N.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
- ASSERT_EQ("3", TestFile.NameAltID);
+ // When
- // Check the LANGUAGE parameter.
+ wxString nameLanguage = testFile.NameLanguage;
- ASSERT_EQ("kw", TestFile.NameLanguage);
+ // Then
- // Check the SORT-AS parameter.
+ ASSERT_EQ("kw", nameLanguage);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenNameDisplayAsIsRetrievedThenValueforNameDisplayAsIsReturned)
+{
+
+ // Check the SORT-AS parameter for N.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ wxString nameDisplayAs = testFile.NameDisplayAs;
+
+ // Then
- ASSERT_EQ("Contact,Test", TestFile.NameDisplayAs);
+ ASSERT_EQ("Contact,Test", nameDisplayAs);
- // Check the extra tokens parameter.
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenNameExtraTokensIsRetrievedThenValueforNameExtraTokensIsReturned)
+{
+
+ // Check the extra tokens parameter for N.
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ wxString nameTokens = testFile.NameTokens;
- ASSERT_EQ("TEST=Yes", TestFile.NameTokens);
+ // Then
+
+ ASSERT_EQ("TEST=Yes", nameTokens);
}
+/* TEMPLATE: PLEASE COPY BEFORE USING IT. */
+
+TEST(ContactLoad, GivenWhenThen)
+{
+
+ std::map<int,wxString>::iterator testFileIter;
+ std::map<int,int>::iterator testFileIntIter;
+ ContactDataObject testFile;
+
+ // Given
+
+ ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+ ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+ // When
+
+ // Then
+
+}
+
+/* END OF TEMPLATE: LOOK UP */
+
TEST(ContactLoad, UIDTest){
ContactDataObject TestFile;
TestFileIter = TestFile.GeneralAddressListGeo.find(0);
ASSERT_NE(TestFile.GeneralAddressListGeo.end(), TestFileIter);
- ASSERT_EQ("\"geo:1.0, 1.0\"", TestFileIter->second);
+ ASSERT_EQ("geo:1.0, 1.0", TestFileIter->second);
// Check the TZ section.
TestFileIter = TestFile.HomeAddressListGeo.find(1);
ASSERT_NE(TestFile.HomeAddressListGeo.end(), TestFileIter);
- ASSERT_EQ("\"geo:4.0, 4.0\"", TestFileIter->second);
+ ASSERT_EQ("geo:4.0, 4.0", TestFileIter->second);
// Check the TZ section.
TestFileIter = TestFile.BusinessAddressListGeo.find(2);
ASSERT_NE(TestFile.BusinessAddressListGeo.end(), TestFileIter);
- ASSERT_EQ("\"geo:7.0, 7.0\"", TestFileIter->second);
+ ASSERT_EQ("geo:7.0, 7.0", TestFileIter->second);
// Check the TZ section.
TestFileIter = TestFile.GeneralTelephoneList.find(0);
ASSERT_NE(TestFile.GeneralTelephoneList.end(), TestFileIter);
- ASSERT_EQ("tel:00000000", TestFileIter->second);
+ ASSERT_EQ("00000000", TestFileIter->second);
+
+ // Check the data type section.
+
+ TestFileIter = TestFile.GeneralTelephoneListDataType.find(0);
+ ASSERT_NE(TestFile.GeneralTelephoneListDataType.end(), TestFileIter);
+ ASSERT_EQ("tel", TestFileIter->second);
// Check the type section.
TestFileIter = TestFile.GeneralTelephoneListTypeInfo.find(0);
ASSERT_NE(TestFile.GeneralTelephoneListTypeInfo.end(), TestFileIter);
- ASSERT_EQ("fax,mobile", TestFileIter->second);
+ ASSERT_EQ("fax,cell", TestFileIter->second.ToStdString());
// Check the ALTID section.
TestFileIter = TestFile.HomeTelephoneList.find(1);
ASSERT_NE(TestFile.HomeTelephoneList.end(), TestFileIter);
- ASSERT_EQ("tel:00001111", TestFileIter->second);
+ ASSERT_EQ("00001111", TestFileIter->second);
+
+ // Check the data type section.
+
+ TestFileIter = TestFile.HomeTelephoneListDataType.find(1);
+ ASSERT_NE(TestFile.HomeTelephoneListDataType.end(), TestFileIter);
+ ASSERT_EQ("tel", TestFileIter->second);
// Check the type section.
TestFileIter = TestFile.BusinessTelephoneList.find(2);
ASSERT_NE(TestFile.BusinessTelephoneList.end(), TestFileIter);
- ASSERT_EQ("tel:22221111", TestFileIter->second);
+ ASSERT_EQ("22221111", TestFileIter->second);
+
+ // Check the data type section.
+
+ TestFileIter = TestFile.BusinessTelephoneListDataType.find(2);
+ ASSERT_NE(TestFile.BusinessTelephoneListDataType.end(), TestFileIter);
+ ASSERT_EQ("tel", TestFileIter->second);
// Check the type section.
TestFileIter = TestFile.GeneralGeographyList.find(0);
ASSERT_NE(TestFile.GeneralGeographyList.end(), TestFileIter);
- ASSERT_EQ("geo:3.5,3.5", TestFileIter->second);
+ ASSERT_EQ("3.5,3.5", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeGeographyList.find(1);
ASSERT_NE(TestFile.HomeGeographyList.end(), TestFileIter);
- ASSERT_EQ("geo:7.0,7.0", TestFileIter->second);
+ ASSERT_EQ("7.0,7.0", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessGeographyList.find(2);
ASSERT_NE(TestFile.BusinessGeographyList.end(), TestFileIter);
- ASSERT_EQ("geo:14.0,14.0", TestFileIter->second);
+ ASSERT_EQ("14.0,14.0", TestFileIter->second);
// Check the ALTID section.
ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter);
ASSERT_EQ("71", TestFileIter->second);
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.PicturesListType.find(0);
+ ASSERT_EQ(TestFile.PicturesListType.end(), TestFileIter);
+
// Check the MEDIATYPE section.
TestFileIter = TestFile.PicturesListMediatype.find(0);
ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter);
ASSERT_EQ("21", TestFileIter->second);
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.PicturesListType.find(1);
+ ASSERT_NE(TestFile.PicturesListType.end(), TestFileIter);
+ ASSERT_EQ("home", TestFileIter->second);
+
// Check the MEDIATYPE section.
TestFileIter = TestFile.PicturesListMediatype.find(1);
ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter);
ASSERT_EQ("91", TestFileIter->second);
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.PicturesListType.find(2);
+ ASSERT_NE(TestFile.PicturesListType.end(), TestFileIter);
+ ASSERT_EQ("work", TestFileIter->second);
+
// Check the MEDIATYPE section.
TestFileIter = TestFile.PicturesListMediatype.find(2);
ASSERT_NE(TestFile.LogosListPID.end(), TestFileIter);
ASSERT_EQ("71", TestFileIter->second);
+ // Check the TYPE section.
+
// Check the MEDIATYPE section.
TestFileIter = TestFile.LogosListMediatype.find(0);
TestFileIter = TestFile.LogosListPID.find(1);
ASSERT_NE(TestFile.LogosListPID.end(), TestFileIter);
ASSERT_EQ("21", TestFileIter->second);
+
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.LogosListType.find(1);
+ ASSERT_NE(TestFile.LogosListType.end(), TestFileIter);
+ ASSERT_EQ("home", TestFileIter->second);
// Check the MEDIATYPE section.
ASSERT_NE(TestFile.LogosListPID.end(), TestFileIter);
ASSERT_EQ("91", TestFileIter->second);
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.LogosListType.find(2);
+ ASSERT_NE(TestFile.LogosListType.end(), TestFileIter);
+ ASSERT_EQ("work", TestFileIter->second);
+
// Check the MEDIATYPE section.
TestFileIter = TestFile.LogosListMediatype.find(2);
ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
ASSERT_EQ("FOODS;STATUS=FAVOURITE;TYPE=CHEESEANDONION", TestFileIter->second.ToStdString());
-}
-
-// TODO: Add tests for the Contact Loading process.
\ No newline at end of file
+}
\ No newline at end of file