From: Steve Brokenshire Date: Sat, 28 Oct 2017 20:18:23 +0000 (+0100) Subject: ContactLoad Unit Tests: Partial conversion to Given/When/Then format X-Git-Tag: release-0.21~15 X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=commitdiff_plain;h=ae4cad18218e9e27555f387be64f02e632b6394c;hp=bfeaecc9ef791d6a2c58cafa71f332eecb606b20 ContactLoad Unit Tests: Partial conversion to Given/When/Then format --- diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index e99b959..e7cbfda 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -19,26 +19,102 @@ #include #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.