Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
ContactLoad Unit Tests: Partial split of tests to Given/When/Then format
[xestiaab/.git] / source / tests / xestiaab_contactload.h
index e2217a1..9239d5e 100644 (file)
@@ -1,6 +1,6 @@
 // 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;
+       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
 
-       // Check that the vCard 4.0 file meets the base specification.
+       ASSERT_EQ(CONTACTLOAD_FILEERROR, testFileLoadStatus);
+
+}
+
+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
        
-       TestFileIntIter = TestFile.GroupsListPref.find(0);
-       ASSERT_NE(TestFile.GroupsListPref.end(), TestFileIntIter);
-       ASSERT_EQ(45, TestFileIntIter->second);
+       testFileIter = testFile.GroupsListAltID.find(0);
        
-       // Check the MEDIATYPE parameter.
+       // 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;
+
+       // Given
        
-       TestFileIter = TestFile.GroupsListMediaType.find(0);
-       ASSERT_NE(TestFile.GroupsListMediaType.end(), TestFileIter);
-       ASSERT_EQ("text/plain", TestFileIter->second);
+       ContactLoadStatus testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
+       ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
        
-       // Check the extra tokens parameter.
+       // When
+               
+       testFileIter = testFile.GroupsListPID.find(0);
+       
+       // 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);
+       
+       // When
+
+       testFileIntIter = testFile.GroupsListPref.find(0);
+       
+       // 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);
-       ASSERT_NE(TestFile.GroupsListTokens.end(), TestFileIter);
-       ASSERT_EQ("EXAMPLE=Meep", TestFileIter->second);
+       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);
        
-       ASSERT_EQ("3", TestFile.NameAltID);
+       // When
+
+       wxString nameAltID = TestFile.NameAltID;
+       
+       // Then
+       
+       ASSERT_EQ("3", nameAltID);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenNameAltIDIsRetrievedThenValueforNameAltIDIsReturned)
+{
+
+       // 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);
+       
+       // When
+       
+       wxString nameLanguage = TestFile.NameLanguage;
+       
+       // Then
+       
+       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);
        
-       // Check the LANGUAGE parameter. 
+       // When
        
-       ASSERT_EQ("kw", TestFile.NameLanguage);
+       wxString nameDisplayAs = TestFile.NameDisplayAs;
        
-       // Check the SORT-AS parameter.
+       // 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;
+       
+       // 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
        
-       ASSERT_EQ("TEST=Yes", TestFile.NameTokens);
+       // Then 
 
 }
 
+/* END OF TEMPLATE: LOOK UP */
+
 TEST(ContactLoad, UIDTest){
 
        ContactDataObject TestFile;
@@ -169,6 +616,55 @@ TEST(ContactLoad, UIDTest){
 
 }
 
+TEST(ContactLoad, ClientPIDMapTests){
+
+       ContactDataObject TestFile;
+
+       ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+       std::map<int,wxString>::iterator TestFileIter;
+
+       // Test the first Client PID Map.
+
+       TestFileIter = TestFile.ClientPIDList.find(0);
+       ASSERT_NE(TestFile.ClientPIDList.end(), TestFileIter);
+       ASSERT_EQ("1;urn;uuid:aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", TestFileIter->second);    
+
+       TestFileIter = TestFile.ClientPIDListTokens.find(0);
+       ASSERT_EQ(TestFile.ClientPIDListTokens.end(), TestFileIter);
+
+       // Test the second Client PID Map.
+
+       TestFileIter = TestFile.ClientPIDList.find(1);
+       ASSERT_NE(TestFile.ClientPIDList.end(), TestFileIter);
+       ASSERT_EQ("2;urn;uuid:ccccccccc-cccc-cccc-cccc-cccccccccccc", TestFileIter->second);
+
+       TestFileIter = TestFile.ClientPIDListTokens.find(1);
+       ASSERT_EQ(TestFile.ClientPIDListTokens.end(), TestFileIter);
+       
+       // Test the third Client PID Map.
+       
+       TestFileIter = TestFile.ClientPIDListTokens.find(2);
+       ASSERT_NE(TestFile.ClientPIDListTokens.end(), TestFileIter);
+       ASSERT_EQ("MEEP=MOO;WOOP=WOO", TestFileIter->second);
+
+       TestFileIter = TestFile.ClientPIDList.find(2);
+       ASSERT_NE(TestFile.ClientPIDList.end(), TestFileIter);
+       ASSERT_EQ("3;urn;uuid:bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", TestFileIter->second);
+
+}
+
+TEST(ContactLoad, RevisionTests){
+
+       ContactDataObject TestFile;
+
+       ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+       
+       ASSERT_EQ("20151227T033000Z", TestFile.Revision);
+       ASSERT_EQ("TEST=YES;DATA=NO;MORE=MAYBE", TestFile.RevisionTokens);
+
+}
+
 TEST(ContactLoad, SourceTests){
 
        ContactDataObject TestFile;
@@ -307,6 +803,38 @@ TEST(ContactLoad, SourceTests){
 
 }
 
+TEST(ContactLoad, XMLTest){
+
+       ContactDataObject TestFile;
+
+       // Check that the vCard 4.0 file loads OK.
+
+       ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+       std::map<int,wxString>::iterator TestFileIter;
+       std::map<int,int>::iterator TestFileIntIter;
+       
+       // Start with the first XML property.
+       
+       // Start with a general source address.
+       
+       TestFileIter = TestFile.XMLList.find(0);
+       ASSERT_NE(TestFile.XMLList.end(), TestFileIter);
+       ASSERT_EQ("<a xmlns=\"http://www.w3.org/1999/xhtml\"\\n"
+    "   href=\"http://example.com/\">Example Page 1</a>", TestFileIter->second);
+
+       TestFileIter = TestFile.XMLList.find(1);
+       ASSERT_NE(TestFile.XMLList.end(), TestFileIter);
+       ASSERT_EQ("<a xmlns=\"http://www.w3.org/1999/xhtml\"\\n"
+    "   href=\"http://example.com/page2.html\">Example Page 2</a>", TestFileIter->second);
+
+       TestFileIter = TestFile.XMLList.find(2);
+       ASSERT_NE(TestFile.XMLList.end(), TestFileIter);
+       ASSERT_EQ("<a xmlns=\"http://www.w3.org/1999/xhtml\"\\n"
+    "   href=\"http://example.com/page3.html\">Example Page 3</a>", TestFileIter->second);
+
+}
+
 TEST(ContactLoad, NicknameTests){
 
        ContactDataObject TestFile;
@@ -716,7 +1244,7 @@ TEST(ContactLoad, AddressTests){
        
        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.
        
@@ -802,7 +1330,7 @@ TEST(ContactLoad, AddressTests){
        
        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.
        
@@ -888,7 +1416,7 @@ TEST(ContactLoad, AddressTests){
        
        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.
        
@@ -1156,13 +1684,19 @@ TEST(ContactLoad, TelephoneTests){
        
        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.
        
@@ -1192,7 +1726,13 @@ TEST(ContactLoad, TelephoneTests){
        
        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.
        
@@ -1228,7 +1768,13 @@ TEST(ContactLoad, TelephoneTests){
        
        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.
        
@@ -1380,7 +1926,7 @@ TEST(ContactLoad, GeographicTests){
        
        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.
        
@@ -1416,7 +1962,7 @@ TEST(ContactLoad, GeographicTests){
        
        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.
        
@@ -1452,7 +1998,7 @@ TEST(ContactLoad, GeographicTests){
        
        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.
        
@@ -2497,6 +3043,11 @@ TEST(ContactLoad, PhotoTests){
        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);
@@ -2546,6 +3097,12 @@ TEST(ContactLoad, PhotoTests){
        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);
@@ -2595,6 +3152,12 @@ TEST(ContactLoad, PhotoTests){
        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);
@@ -2658,6 +3221,8 @@ TEST(ContactLoad, LogoTests){
        ASSERT_NE(TestFile.LogosListPID.end(), TestFileIter);
        ASSERT_EQ("71", TestFileIter->second);
        
+       // Check the TYPE section.
+               
        // Check the MEDIATYPE section.
        
        TestFileIter = TestFile.LogosListMediatype.find(0);
@@ -2706,6 +3271,12 @@ TEST(ContactLoad, LogoTests){
        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.
        
@@ -2756,6 +3327,12 @@ TEST(ContactLoad, LogoTests){
        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);
@@ -4186,6 +4763,4 @@ TEST(ContactLoad, XTokenTest){
        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
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy