Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Unit Tests: Updated copyright year on modified files
[xestiaab/.git] / source / tests / xestiaab_contactload.h
index 3d12c8d..cb625bb 100644 (file)
@@ -1,6 +1,6 @@
 // xestiaab_contactload.h - Xestia Address Book Contact Load Unit Tests.
 //
-// (c) 2012-2015 Xestia Software Development.
+// (c) 2012-2017 Xestia Software Development.
 //
 // This file is part of Xestia Address Book.
 //
 #include <gtest/gtest.h>
 #include "../contacteditor/cdo/ContactDataObject.h"
 
-TEST(ContactLoad, ContactLoadTests){
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithMissingFileThenReturnFileMissingError)
+{
 
-       ContactDataObject TestFile;
+       // Given
 
-       // Check that the file given is not missing.
+       ContactDataObject testFile;
        
-       ASSERT_EQ(CONTACTLOAD_FILEMISSING, TestFile.LoadFile("MissingFile.vcf"));
+       // When
+
+       ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+       testFile.LoadFile("MissingFile.vcf");
        
-       // Check that the file given does not have an error when attempting to
-       // open it. 
+       // Then
+
+       ASSERT_EQ(CONTACTLOAD_FILEMISSING, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithInvalidPermissionsSetThenReturnInvalidPermissionsError)
+{
+
+       // Given
+       
+       ContactDataObject testFile;
+       
+       // When
+
+       ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+       testFileLoadStatus = testFile.LoadFile("InvalidPermissions.vcf");
+       
+       // Then
+
+       ASSERT_EQ(CONTACTLOAD_FILEERROR, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithInvalidFormatThenReturnInvalidFormatError)
+{
+
+       // Given
+       
+       ContactDataObject testFile;
+       
+       // When
+
+       ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+       testFileLoadStatus = testFile.LoadFile("LoadCheck-Load1-v3.vcf");
+       
+       // Then
+
+       ASSERT_EQ(CONTACTLOAD_FILEINVALIDFORMAT, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithNonMeetingBaseSpecificationThenReturnFileBaseSpecificationError)
+{
+
+       // Given
+
+       ContactDataObject testFile;
        
-       ASSERT_EQ(CONTACTLOAD_FILEERROR, TestFile.LoadFile("InvalidPermissions.vcf"));
+       // When
        
-       // Check that the file is a valid vCard 4.0 file.
+       ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+       testFileLoadStatus = testFile.LoadFile("LoadCheck-Load3.vcf");
+
+       // Then
+
+       ASSERT_EQ(CONTACTLOAD_FILEBASESPECFAIL, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledThenContactLoadedOK)
+{
+
+       // Given
+
+       ContactDataObject testFile;
        
-       ASSERT_EQ(CONTACTLOAD_FILEINVALIDFORMAT, TestFile.LoadFile("LoadCheck-Load1-v3.vcf"));
+       // When
 
-       // Check that the vCard 4.0 file meets the base specification.
+       ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL;
+       testFileLoadStatus = testFile.LoadFile("LoadCheck-Load4.vcf");
        
-       ASSERT_EQ(CONTACTLOAD_FILEBASESPECFAIL, TestFile.LoadFile("LoadCheck-Load3.vcf"));
+       // Then
+
+       ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus);
+
+}
+
+TEST(ContactLoad, ContactLoadTests){
+
+       ContactDataObject TestFile;
+       
+       // Check that the file given does not have an error when attempting to
+       // open it. 
 
        // Check that the vCard 4.0 file loads OK.
 
@@ -797,7 +873,7 @@ TEST(ContactLoad, AddressTests){
        
        TestFileIter = TestFile.GeneralAddressListGeo.find(0);
        ASSERT_NE(TestFile.GeneralAddressListGeo.end(), TestFileIter);
-       ASSERT_EQ("\"geo:1.0, 1.0\"", TestFileIter->second);
+       ASSERT_EQ("geo:1.0, 1.0", TestFileIter->second);
 
        // Check the TZ section.
        
@@ -883,7 +959,7 @@ TEST(ContactLoad, AddressTests){
        
        TestFileIter = TestFile.HomeAddressListGeo.find(1);
        ASSERT_NE(TestFile.HomeAddressListGeo.end(), TestFileIter);
-       ASSERT_EQ("\"geo:4.0, 4.0\"", TestFileIter->second);
+       ASSERT_EQ("geo:4.0, 4.0", TestFileIter->second);
 
        // Check the TZ section.
        
@@ -969,7 +1045,7 @@ TEST(ContactLoad, AddressTests){
        
        TestFileIter = TestFile.BusinessAddressListGeo.find(2);
        ASSERT_NE(TestFile.BusinessAddressListGeo.end(), TestFileIter);
-       ASSERT_EQ("\"geo:7.0, 7.0\"", TestFileIter->second);
+       ASSERT_EQ("geo:7.0, 7.0", TestFileIter->second);
 
        // Check the TZ section.
        
@@ -1479,7 +1555,7 @@ TEST(ContactLoad, GeographicTests){
        
        TestFileIter = TestFile.GeneralGeographyList.find(0);
        ASSERT_NE(TestFile.GeneralGeographyList.end(), TestFileIter);
-       ASSERT_EQ("geo:3.5,3.5", TestFileIter->second);
+       ASSERT_EQ("3.5,3.5", TestFileIter->second);
        
        // Check the ALTID section.
        
@@ -1515,7 +1591,7 @@ TEST(ContactLoad, GeographicTests){
        
        TestFileIter = TestFile.HomeGeographyList.find(1);
        ASSERT_NE(TestFile.HomeGeographyList.end(), TestFileIter);
-       ASSERT_EQ("geo:7.0,7.0", TestFileIter->second);
+       ASSERT_EQ("7.0,7.0", TestFileIter->second);
        
        // Check the ALTID section.
        
@@ -1551,7 +1627,7 @@ TEST(ContactLoad, GeographicTests){
        
        TestFileIter = TestFile.BusinessGeographyList.find(2);
        ASSERT_NE(TestFile.BusinessGeographyList.end(), TestFileIter);
-       ASSERT_EQ("geo:14.0,14.0", TestFileIter->second);
+       ASSERT_EQ("14.0,14.0", TestFileIter->second);
        
        // Check the ALTID section.
        
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