X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiaab_contactload.h;h=f40eeb993ae248d12f0facee9f2b45413897261a;hb=702ac5127f25499fcd966ae5d9bbc9a6c8e37299;hp=b9b7f46463f68a0a278ff70cda4f9339fb6d2602;hpb=e7eaa503e46395e1126c901b1ff0d25388259ba5;p=xestiaab%2F.git diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index b9b7f46..f40eeb9 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -1,3 +1,82 @@ +// xestiaab_contactload.h - Xestia Address Book Contact Load Unit Tests. +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// 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); + +} // TODO: Add tests for the Contact Loading process. \ No newline at end of file