// xestiaab_contactsave.h - Xestia Address Book Contact Save 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/cdo/ContactDataObject.h"
TEST(ContactSave, ContactSaveTests){
ContactDataObject TestFile1;
ContactDataObject TestFile2;
ContactDataObject TestFile3;
wxString SaveData;
wxString SaveDataCompare = "BEGIN:VCARD\n"
"VERSION:4.0\n"
"PRODID:-//Xestia//Address Book Unit Testing//KW\n"
"FN:Test vCard\n"
"TITLE:Knight of the Tests\n"
"TITLE:The Tester of Cornwall\n"
"END:VCARD";
ASSERT_EQ(CONTACTLOAD_OK, TestFile1.LoadFile("LoadCheck-Load1.vcf"));
ASSERT_EQ(CONTACTSAVE_OK, TestFile1.SaveString(&SaveData));
ASSERT_EQ(SaveDataCompare, SaveData);
ASSERT_EQ(CONTACTLOAD_OK, TestFile2.LoadFile("LoadCheck-Load2.vcf"));
SaveData.clear();
SaveDataCompare = "BEGIN:VCARD\n"
"VERSION:4.0\n"
"PRODID:-//Xestia//Address Book Unit Testing//KW\n"
"FN:Test vCard\n"
"TITLE:The Third Title\n"
"TITLE:Knight of the Tests\n"
"TITLE:The Tester of Cornwall\n"
"END:VCARD";
ASSERT_EQ(CONTACTSAVE_OK, TestFile2.SaveString(&SaveData));
ASSERT_EQ(SaveDataCompare, SaveData);
SaveData.clear();
SaveDataCompare = "BEGIN:VCARD\n"
"VERSION:4.0\n"
"PRODID:-//Xestia//Address Book Unit Testing//KW\n"
"UID:903588-9082374-989120310-AAFECDBCDF\n"
"KIND:individual\n"
"XML:Ex\n"
" ample Page 1\n"
"XML;ALTID=3:Example Page 2\n"
"XML;ALTID=5:Example Page 3\n"
"SOURCE;ALTID=74;MEDIATYPE=text/plain;PID=71;PREF=72;STATUS=FEED:http://exampl\n"
" e.com/source/sourcea.vcf\n"
"SOURCE;TYPE=home;ALTID=84;MEDIATYPE=text/plainpaper;PID=81;PREF=82;STATUS=ONL\n"
" INE:http://example.com/source/sourceb.vcf\n"
"SOURCE;TYPE=work;ALTID=94;MEDIATYPE=text/sandpaper;PID=91;PREF=92;STATUS=OFFL\n"
" INE:http://example.com/source/sourcec.vcf\n"
"CLIENTPIDMAP:1;urn;uuid:aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa\n"
"CLIENTPIDMAP:2;urn;uuid:ccccccccc-cccc-cccc-cccc-cccccccccccc\n"
"CLIENTPIDMAP;MEEP=MOO;WOOP=WOO:3;urn;uuid:bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb\n"
" bb\n"
"FN;TYPE=work;LANGUAGE=kw;ALTID=500;PID=40;PREF=45;EXAMPLE=Baaa:Test Contact\n"
"NICKNAME;ALTID=35;LANGUAGE=kw;PID=50;PREF=40;YAY=Nope;Beep=Boop:Tester\n"
"NICKNAME;TYPE=home;ALTID=17;LANGUAGE=en;PID=39;PREF=78;YAY=Yep;Beep=Boop:Test\n"
" y\n"
"NICKNAME;TYPE=work;ALTID=99;LANGUAGE=en-GB;PID=10;PREF=1;YAY=Maybe;Boop=Boing\n"
" :The Testing One\n"
"TITLE;ALTID=20;LANGUAGE=text/plain;PID=21;PREF=22;EEP=LIGHT:Lord of Light\n"
"TITLE;TYPE=home;ALTID=30;LANGUAGE=grass/dry;PID=31;PREF=32;EEP=DARK:Lord of D\n"
" arkness\n"
"TITLE;TYPE=work;ALTID=40;LANGUAGE=moths/eew;PID=41;PREF=42;EEP=BOTH:Master of\n"
" the Light & Darkness\n"
"END:VCARD";
ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf"));
ASSERT_EQ(CONTACTSAVE_OK, TestFile3.SaveString(&SaveData));
std::cout << SaveData << std::endl;
std::cout << SaveDataCompare << std::endl;
ASSERT_EQ(SaveDataCompare, SaveData);
}