Browse Source

Added "intended no. of sentneces" unit test.

Created a DefaultSentence literal in InputGeneration. (For "clean" function purposes mostly.)
master
Craig Oates 6 years ago
parent
commit
8273cc0679
  1. 5
      TestCentre/InputGeneration.fs
  2. 19
      TestCentre/UnitTests.fs

5
TestCentre/InputGeneration.fs

@ -20,4 +20,7 @@
let ValidFileInput () =
let testInputs = [|ConsoleWaterworks; DesktopClock; TestPost; WordGenerator|]
let index = Random().Next(0, testInputs.Length)
testInputs.[index]
testInputs.[index]
[<Literal>]
let DefaultTestSentence = "This is a sentence. And, so is this. This shouldn't be here! How about this? No!"

19
TestCentre/UnitTests.fs

@ -6,6 +6,7 @@
open System
open System.IO
open InputGeneration
open System.Text.RegularExpressions
module ``File Access Tests`` =
@ -111,14 +112,28 @@
module ``Contents Tests`` =
// This function is mostly for the "cleaning" functions, hence placement.
// Feel free to use through this module if needed.
let private countSentences text =
Regex.Split(text, @"(?<=[\.\!\?]\s)")
|> Array.length
[<Fact>]
let ``CleanResult returns a string with a full stop`` () =
let text = "This is a sentence. And, so is this. This shouldn't be here! How about this? No!"
let result =
Pancake.CleanResult (Random().Next(1, 6)) text
Pancake.CleanResult (Random().Next(1, 5)) DefaultTestSentence
|> Async.RunSynchronously
Assert.Contains(".", result)
[<Fact>]
let ``CleanResult returns intended number of sentences`` () =
let desiredSentencesCount = (Random().Next(1,5))
let result =
Pancake.CleanResult desiredSentencesCount DefaultTestSentence
|> Async.RunSynchronously
|> countSentences
Assert.Equal(desiredSentencesCount, (result - 1))
// YOU ARE HERE...
// - ADD TESTS FOR "CLEANING" FUNCTIONS

Loading…
Cancel
Save