X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiaab_contactload.h;h=c573175a849caa464152d12faaa8b847728655b1;hb=b19bbc6c6d83edfefba9c98e78a57d21eb8aa1a8;hp=090f79441d6751266c35ab9c7519b325c1b3bb8d;hpb=b16a0672e8bcbc1840a5f2284dbf562963aca6b1;p=xestiaab%2F.git diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index 090f794..c573175 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -17,5 +17,140 @@ // with Xestia Address Book. If not, see #include +#include "../contacteditor/ContactDataObject.h" + +TEST(ContactLoad, ContactLoadTests){ + + ContactDataObject TestFile; + + // Check that the file given is not missing. + + ASSERT_EQ(CONTACTLOAD_FILEMISSING, TestFile.LoadFile("MissingFile.vcf")); + + // Check that the file given does not have an error when attempting to + // open it. + + ASSERT_EQ(CONTACTLOAD_FILEERROR, TestFile.LoadFile("InvalidPermissions.vcf")); + + // Check that the file is a valid vCard 4.0 file. + + ASSERT_EQ(CONTACTLOAD_FILEINVALIDFORMAT, TestFile.LoadFile("LoadCheck-Load1-v3.vcf")); + + // Check that the vCard 4.0 file meets the base specification. + + ASSERT_EQ(CONTACTLOAD_FILEBASESPECFAIL, TestFile.LoadFile("LoadCheck-Load3.vcf")); + + // Check that the vCard 4.0 file loads OK. + + ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf")); + + // Check that the kind status has been set. (KIND). + + ASSERT_NE(CONTACTKIND_NONE, TestFile.ContactKind); + ASSERT_EQ(CONTACTKIND_INDIVIDUAL, TestFile.ContactKind); + + // Check that the groups have been read (MEMBER). + + std::map::iterator TestFileIter; + std::map::iterator TestFileIntIter; + + TestFileIter = TestFile.GroupsList.find(0); + + 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); + + // Check the PID parameter. + + TestFileIter = TestFile.GroupsListPID.find(0); + ASSERT_NE(TestFile.GroupsListPID.end(), TestFileIter); + ASSERT_EQ("40", TestFileIter->second); + + // Check the PREF parameter. + + TestFileIntIter = TestFile.GroupsListPref.find(0); + ASSERT_NE(TestFile.GroupsListPref.end(), TestFileIntIter); + ASSERT_EQ(45, TestFileIntIter->second); + + // Check the MEDIATYPE parameter. + + TestFileIter = TestFile.GroupsListMediaType.find(0); + ASSERT_NE(TestFile.GroupsListMediaType.end(), TestFileIter); + ASSERT_EQ("text/plain", TestFileIter->second); + + // Check the extra tokens parameter. + + TestFileIter = TestFile.GroupsListTokens.find(0); + ASSERT_NE(TestFile.GroupsListTokens.end(), TestFileIter); + ASSERT_EQ("EXAMPLE=Meep", TestFileIter->second); + + // Check that the formatted name has been read (FN). + + TestFileIter = TestFile.FullNamesList.find(0); + ASSERT_NE(TestFile.FullNamesList.end(), TestFileIter); + ASSERT_EQ("Test Contact", TestFileIter->second); + + // Check the TYPE parameter. + + TestFileIter = TestFile.FullNamesListType.find(0); + ASSERT_NE(TestFile.FullNamesListType.end(), TestFileIter); + ASSERT_EQ("work", TestFileIter->second); + + // Check the LANGUAGE parameter. + + TestFileIter = TestFile.FullNamesListLanguage.find(0); + ASSERT_NE(TestFile.FullNamesListLanguage.end(), TestFileIter); + ASSERT_EQ("kw", TestFileIter->second); + + // Check the ALTID parameter. + + TestFileIter = TestFile.FullNamesListAltID.find(0); + 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); + + // Check the PREF parameter. + + TestFileIntIter = TestFile.FullNamesListPref.find(0); + ASSERT_NE(TestFile.FullNamesListPref.end(), TestFileIntIter); + ASSERT_EQ(45, TestFileIntIter->second); + + // Check for the extra tokens parameter. + + TestFileIter = TestFile.FullNamesListTokens.find(0); + ASSERT_NE(TestFile.FullNamesListTokens.end(), TestFileIter); + ASSERT_EQ("EXAMPLE=Baaa", TestFileIter->second); + + // Check that the name has been read (N). + + ASSERT_EQ("Test", TestFile.NameForename); + + // Check the ALTID parameter. + + ASSERT_EQ("3", TestFile.NameAltID); + + // Check the LANGUAGE parameter. + + ASSERT_EQ("kw", TestFile.NameLanguage); + + // Check the SORT-AS parameter. + + ASSERT_EQ("Contact,Test", TestFile.NameDisplayAs); + + // Check the extra tokens parameter. + + ASSERT_EQ("TEST=Yes", TestFile.NameTokens); + +} // TODO: Add tests for the Contact Loading process. \ No newline at end of file