Browse Source

Updated the "contains a full stop" property test -- RequestRandomText.

Added Helper module to property tests.
master
Craig Oates 6 years ago
parent
commit
d4f75e113f
  1. 17
      TestCentre/Helpers.fs
  2. 7
      TestCentre/PropertyTests.fs
  3. 24
      TestCentre/UnitTests.fs

17
TestCentre/Helpers.fs

@ -1,14 +1,17 @@
module Helpers
open System.Text.RegularExpressions
// The main aim of these functions is to reduce code in the unit and property tests.
// You will most-likely find them in the "contents" tests (for unit and property).
let CountSentences text =
let count =
Regex.Split(text, @"(?<=[\.\!\?]\s)")
|> Array.length
count
let countSentences text =
let count =
Regex.Split(text, @"(?<=[\.\!\?]\s)")
|> Array.length
count
let endsAsIntended (text: string) =
let EndsAsIntended (text: string) =
match text.Chars (text.Length - 1) with
| '.' -> true
| '!' -> true

7
TestCentre/PropertyTests.fs

@ -6,7 +6,7 @@
open WetPancake
open TestingConstants
open System.Diagnostics
open System
open Helpers
open InputGeneration
(* End of Session Note - Monday 23rd July
@ -94,11 +94,12 @@
module ``Contents Test`` =
[<Property>]
let ``RequestRandomText returns a string which contains a full stop`` () =
let ``RequestRandomText returns a string which ends with the correct end-token`` () =
let test () =
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
let results = Assert.Contains(".", test())
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
[<Property>]

24
TestCentre/UnitTests.fs

@ -118,7 +118,7 @@
let result =
Pancake.CleanResult desiredSentencesCount DefaultTestSentence
|> Async.RunSynchronously
|> countSentences
|> CountSentences
Assert.Equal(desiredSentencesCount, result)
[<Fact>]
@ -134,7 +134,7 @@
let result =
Pancake.RequestCleanTextAsync (ValidGibberishLevelInput()) desiredSentencesCount
|> Async.RunSynchronously
|> countSentences
|> CountSentences
Assert.Equal(desiredSentencesCount, result)
[<Fact>]
@ -143,7 +143,7 @@
let result =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) desiredSentencesCount ConsoleWaterworks
|> Async.RunSynchronously
|> countSentences
|> CountSentences
Assert.Equal(desiredSentencesCount, result)
[<Fact>]
@ -152,7 +152,7 @@
let result =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) desiredSentencesCount DesktopClock
|> Async.RunSynchronously
|> countSentences
|> CountSentences
Assert.Equal(desiredSentencesCount, result)
[<Fact>]
@ -161,7 +161,7 @@
let result =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) desiredSentencesCount TestPost
|> Async.RunSynchronously
|> countSentences
|> CountSentences
Assert.Equal(desiredSentencesCount, result)
[<Fact>]
@ -170,7 +170,7 @@
let result =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) desiredSentencesCount WordGenerator
|> Async.RunSynchronously
|> countSentences
|> CountSentences
Assert.Equal(desiredSentencesCount, result)
[<Fact>]
@ -178,7 +178,7 @@
let result =
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
|> endsAsIntended
|> EndsAsIntended
Assert.True(result)
[<Fact>]
@ -186,7 +186,7 @@
let result =
Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
|> endsAsIntended
|> EndsAsIntended
Assert.True(result)
[<Fact>]
@ -194,7 +194,7 @@
let result =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
|> endsAsIntended
|> EndsAsIntended
Assert.True(result)
[<Fact>]
@ -202,7 +202,7 @@
let result =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
|> endsAsIntended
|> EndsAsIntended
Assert.True(result)
[<Fact>]
@ -210,7 +210,7 @@
let result =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
|> endsAsIntended
|> EndsAsIntended
Assert.True(result)
[<Fact>]
@ -218,5 +218,5 @@
let result =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
|> endsAsIntended
|> EndsAsIntended
Assert.True(result)
Loading…
Cancel
Save