diff --git a/TestCentre/TestCentre.fsproj b/TestCentre/TestCentre.fsproj index 523af0d..8b00856 100644 --- a/TestCentre/TestCentre.fsproj +++ b/TestCentre/TestCentre.fsproj @@ -75,6 +75,7 @@ PreserveNewest + diff --git a/TestCentre/TestingConstants.fs b/TestCentre/TestingConstants.fs index decc141..1d5be43 100644 --- a/TestCentre/TestingConstants.fs +++ b/TestCentre/TestingConstants.fs @@ -1,21 +1,33 @@ module internal TestingConstants -// Use these to reference the built-in .txt files in Test Centre. +(* Valid Text Files +=================================================================================================================== +Use these to quickly reference the built-in .txt files within Test Centre. +They should, also, mimic the .txt files in Wet Pancake/textFiles. +If you are noticing inconsistent behaviour between Test Centre and Wet Pancake, make sure these files match. *) + +[] +let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt" [] let DesktopClock = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.txt" [] -let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt" +let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt" [] let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt" -[] -let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt" +(* Invalid Input +=================================================================================================================== +These values should not mimic or reference anything in Wet Pancake. +Below should just be dummy content/values. *) [] let InvalidFilePathInput = __SOURCE_DIRECTORY__ + @"Invalid/file.txt" [] let InvalidFileTypeInput = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.doc" + +[] +let InvalidTextFile = __SOURCE_DIRECTORY__ + @"\TextFiles\invalid-text.txt" diff --git a/TestCentre/TextFiles/invalid-text.txt b/TestCentre/TextFiles/invalid-text.txt new file mode 100644 index 0000000..234482a --- /dev/null +++ b/TestCentre/TextFiles/invalid-text.txt @@ -0,0 +1 @@ +This file does not contain a vaild end token diff --git a/TestCentre/UnitTests.fs b/TestCentre/UnitTests.fs index 94051a5..df4f7d5 100644 --- a/TestCentre/UnitTests.fs +++ b/TestCentre/UnitTests.fs @@ -14,25 +14,30 @@ The WetPancake library does not expose the file access functions so the .txt files are mirrored here (in Test Centre). The mirroring, also, doubles up as sample files to pass into WetPancake. *) - [] - let ``desktop-clock-info can be found`` () = - let result = File.Exists DesktopClock - Assert.Equal(true, result); - [] let ``console-waterworks-announcements can be found`` () = let result = File.Exists ConsoleWaterworks - Assert.Equal(true, result); - + Assert.True result + [] - let ``word-generator can be found`` () = - let result = File.Exists WordGenerator - Assert.Equal(true, result); + let ``desktop-clock-info can be found`` () = + let result = File.Exists DesktopClock + Assert.True result + [] + let ``invalid-text can be found`` () = + let result = File.Exists InvalidTextFile + Assert.True result + [] let ``test-post can be found`` () = let result = File.Exists TestPost - Assert.Equal(true, result) + Assert.True result + + [] + let ``word-generator can be found`` () = + let result = File.Exists WordGenerator + Assert.True result module ``Null Tests`` = @@ -112,7 +117,7 @@ [] let ``TextIsValid does not return a null`` () = - let result = Pancake.TextInFileIsValidAsync "This is string of text contains a valid end token." + let result = Pancake.TextInFileIsValidAsync TestPost Assert.NotNull result module ``Contents Tests`` = @@ -272,4 +277,19 @@ Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator |> Async.RunSynchronously |> EndsAsIntended - Assert.True(result) \ No newline at end of file + Assert.True(result) + + [] + let ``TextInFileIsValid returns correct boolean value when processing the files text`` () = + let trueResult = + Pancake.TextInFileIsValidAsync TestPost + |> Async.RunSynchronously + let falseResult = + Pancake.TextInFileIsValidAsync InvalidTextFile + |> Async.RunSynchronously + let outcomes = (trueResult, falseResult) + let finalResult = + match outcomes with + | true, false -> true + | _, _ -> false + Assert.True finalResult \ No newline at end of file