Browse Source

Added invalid-text.txt to Test Centre.

Rearranged TestingConstants.fs and UnitTests.fs.
Refactored File Access unit tests (C# habits).
Wrote contents test in UnitTests.fs for TextInFileIsValid function.
master
Craig Oates 6 years ago
parent
commit
4597543140
  1. 1
      TestCentre/TestCentre.fsproj
  2. 20
      TestCentre/TestingConstants.fs
  3. 1
      TestCentre/TextFiles/invalid-text.txt
  4. 46
      TestCentre/UnitTests.fs

1
TestCentre/TestCentre.fsproj

@ -75,6 +75,7 @@
<Content Include="TextFiles\desktop-clock-info.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TextFiles\invalid-text.txt" />
</ItemGroup>
<ItemGroup>
<Reference Include="FsCheck">

20
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. *)
[<Literal>]
let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt"
[<Literal>]
let DesktopClock = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.txt"
[<Literal>]
let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt"
let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt"
[<Literal>]
let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt"
[<Literal>]
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. *)
[<Literal>]
let InvalidFilePathInput = __SOURCE_DIRECTORY__ + @"Invalid/file.txt"
[<Literal>]
let InvalidFileTypeInput = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.doc"
[<Literal>]
let InvalidTextFile = __SOURCE_DIRECTORY__ + @"\TextFiles\invalid-text.txt"

1
TestCentre/TextFiles/invalid-text.txt

@ -0,0 +1 @@
This file does not contain a vaild end token

46
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. *)
[<Fact>]
let ``desktop-clock-info can be found`` () =
let result = File.Exists DesktopClock
Assert.Equal(true, result);
[<Fact>]
let ``console-waterworks-announcements can be found`` () =
let result = File.Exists ConsoleWaterworks
Assert.Equal(true, result);
Assert.True result
[<Fact>]
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
[<Fact>]
let ``invalid-text can be found`` () =
let result = File.Exists InvalidTextFile
Assert.True result
[<Fact>]
let ``test-post can be found`` () =
let result = File.Exists TestPost
Assert.Equal(true, result)
Assert.True result
[<Fact>]
let ``word-generator can be found`` () =
let result = File.Exists WordGenerator
Assert.True result
module ``Null Tests`` =
@ -112,7 +117,7 @@
[<Fact>]
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)
Assert.True(result)
[<Fact>]
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
Loading…
Cancel
Save