Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Setup unit test for testing the LoadCheck-Load1.vcf file
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 26 Jun 2016 22:33:21 +0000 (23:33 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 26 Jun 2016 22:33:21 +0000 (23:33 +0100)
source/contacteditor/cdo/ContactDataObject-Save.cpp
source/tests/xestiaab_contactsave.h

index 3b13b4d..8a0f2b7 100644 (file)
@@ -23,7 +23,52 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
        
        ContactSaveStatus SaveDataStatus = CONTACTSAVE_UNITTESTFAIL;
        
+       // Write the header for the vCard data file.
        
+       SaveData->Append("BEGIN:VCARD\n");
+       SaveData->Append("VERSION:4.0\n");
+       
+       // Write the product ID.
+       
+#ifdef XAB_UNITTEST
+       
+       SaveData->Append("PRODID:-//Xestia//Address Book Unit Testing//KW\n");
+       
+#else
+       
+       SaveData->Append(wxT("-//Xestia//Address Book Version "));
+       SaveData->Append(wxT(XSDAB_VERSION));
+       SaveData->Append(wxT("//KW\n"));
+       
+#endif
+       
+       // Process FN.
+       
+       for (std::map<int, wxString>::iterator FNIter = FullNamesList.begin();
+               FNIter != FullNamesList.end(); FNIter++){
+               
+               SaveData->Append("FN:");
+               SaveData->Append(FNIter->second);
+               SaveData->Append("\n");
+                       
+       }
+       
+       // Process TITLE.
+
+       for (std::map<int, wxString>::iterator TitleIter = GeneralTitleList.begin();
+               TitleIter != GeneralTitleList.end(); TitleIter++){
+               
+               SaveData->Append("TITLE:");
+               SaveData->Append(TitleIter->second);
+               SaveData->Append("\n");
+                       
+       }
+       
+       // Write the end part of the vCard data file.
+       
+       SaveData->Append("END:VCARD");
+       
+       SaveDataStatus = CONTACTSAVE_OK;
        
        return SaveDataStatus;
        
index 46608f2..b8834b8 100644 (file)
@@ -24,9 +24,17 @@ TEST(ContactSave, ContactSaveTests){
        
        ContactDataObject TestFile1;
        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);
        
 }
\ 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