#include "ContactDataObject.h"
#include "../../version.h"
+ContactSaveStatus ContactDataObject::SaveFile(wxString SaveFilename){
+
+ // Get the data using SaveString.
+
+ wxString SaveData = "";
+ SaveString(&SaveData);
+
+ // Open a file and try to write into it.
+
+ wxFile ContactFile;
+
+ if (!ContactFile.Open(SaveFilename, wxFile::write, wxS_DEFAULT)){
+
+ return CONTACTSAVE_FILEERROR;
+
+ }
+
+ if (ContactFile.Write(SaveData, wxConvUTF8) == false){
+
+ return CONTACTSAVE_WRITEERROR;
+
+ }
+
+ ContactFile.Close();
+
+ return CONTACTSAVE_OK;
+
+}
+
ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
ContactSaveStatus SaveDataStatus = CONTACTSAVE_UNITTESTFAIL;
ASSERT_EQ(SaveDataCompare, SaveData);
+}
+
+TEST(ContactSave, ContactSaveFileTests){
+
+ ContactDataObject TestFile1;
+ ContactDataObject TestFile2;
+ ContactDataObject TestFile3;
+
+ ASSERT_EQ(CONTACTLOAD_OK, TestFile1.LoadFile("LoadCheck-Load1.vcf"));
+ ASSERT_EQ(CONTACTSAVE_OK, TestFile1.SaveFile("SaveCheck-Save1.vcf"));
+ ASSERT_EQ(CONTACTSAVE_FILEERROR, TestFile1.SaveFile("/invalidfile"));
+
+ ASSERT_EQ(CONTACTLOAD_OK, TestFile2.LoadFile("LoadCheck-Load2.vcf"));
+ ASSERT_EQ(CONTACTSAVE_OK, TestFile2.SaveFile("SaveCheck-Save2.vcf"));
+
+ ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf"));
+ ASSERT_EQ(CONTACTSAVE_OK, TestFile3.SaveFile("SaveCheck-Save4.vcf"));
+
}
\ No newline at end of file