The purpose of this repository is to provide a way for people to generate random "placeholder text" -- with a Markov Chain. https://www.craigoates.net/Software/project/12
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

241 lines
10 KiB

module PropertyTests
open FsCheck
open global.Xunit
open FsCheck.Xunit
open WetPancake
open TestingConstants
open System.Diagnostics
open Helpers
open InputGeneration
(* End of Session Note - Monday 23rd July/Tuesday 24th July
==================================================================================================================
[x] Remove the "contains a full stop" tests -- no longer needed due to change in functionality.
[...] Update the "end with a full-stop" tests -- expanded the way a sentence can end.
[...] Add returns intended sentences for "clean" functions.
[x] Double check UnitTests.fs
*)
module ``Null Tests`` =
[<Property>]
let ``Request Random Text does not return a null when using the built-in random settings`` () =
let test =
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
let results = Assert.NotNull test
Check.Quick results
[<Property>]
let ``Request Text does not return a null when using fixed input parameters`` () =
// Change the values for a quick way to manually test the (test) code.
let test ()=
Pancake.RequestTextAsync 5 5
|> Async.RunSynchronously
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``Request Text does not return a null when using a random gibberish level`` () =
let test ()=
Pancake.RequestTextAsync (ValidGibberishLevelInput()) 5
|> Async.RunSynchronously
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``Request Text does not return a null when using a random sentence count`` () =
let test () =
Pancake.RequestTextAsync 5 (ValidSentencesInput())
|> Async.RunSynchronously
let results = Assert.NotNull test
Check.Quick results
[<Property>]
let ``RequestTextFromFile does not return a null when using console-waterworks-info`` () =
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile does not return a null when using desktop-clock-info`` () =
let test ()=
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile does not return a null when using word-generator`` () =
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile does not return a null when using test-post`` () =
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``RequestAllTemplateFiles does not return a null`` () =
let test () =
Pancake.RequestAllTemplateFilesAsync ()
|> Async.RunSynchronously
let results = Assert.NotNull (test())
Check.Quick results
module ``Contents Test`` =
[<Property>]
let ``CleanResult returns a string which ends with the correct end-token`` () =
let test () =
Pancake.CleanResultAsync (DefaultSentenceCount()) DefaultTestSentence
|> Async.RunSynchronously
|> EndsAsIntended
let results () = Assert.True(test())
Check.Quick (results())
[<Property>]
let ``CleanResult returns intended number of sentences`` () =
let desiredSentencesCount = (DefaultSentenceCount())
let test () =
Pancake.CleanResultAsync desiredSentencesCount DefaultTestSentence
|> Async.RunSynchronously
|> CountSentences
let results () = Assert.Equal(desiredSentencesCount , test())
Check.Quick (results())
[<Property>]
let ``RequestAllTemplateFiles does not return an empty list`` () =
let test () =
Pancake.RequestAllTemplateFilesAsync ()
|> Async.RunSynchronously
let results = Assert.NotEmpty (test())
Check.Quick results
[<Property>]
let ``RequestCleanText returns a string which ends with the correct end-token`` () =
let test () =
Pancake.RequestCleanTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
|> EndsAsIntended
let results () = Assert.True(test())
Check.Quick results
[<Property>]
let ``RequestCleanText returns intended number of sentences`` () =
let desiredSentencesCount = (ValidSentencesInput())
let test () =
Pancake.RequestCleanTextAsync (ValidGibberishLevelInput()) desiredSentencesCount
|> Async.RunSynchronously
|> CountSentences
let results = Assert.Equal(desiredSentencesCount, test())
Check.Quick results
// clean text from file ends with correct end-token
[<Property>]
let ``RequestCleanTextFromFile returns a string which ends with the correct end-token when using console-waterworks-announcement`` () =
let test () =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
|> EndsAsIntended
let results () = Assert.True(test())
Check.Quick (results())
[<Property>]
let ``RequestCleanTextFromFile returns a string which ends with the correct end-token when using desktop-clock-info`` () =
let test () =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
|> EndsAsIntended
let results () = Assert.True(test())
Check.Quick (results())
[<Property>]
let ``RequestCleanTextFromFile returns a string which ends with the correct end-token when using test-post`` () =
let test () =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
|> EndsAsIntended
let results () = Assert.True(test())
Check.Quick (results())
[<Property>]
let ``RequestCleanTextFromFile returns a string which ends with the correct end-token when using word-generator`` () =
let test () =
Pancake.RequestCleanTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
|> EndsAsIntended
let results () = Assert.True(test())
Check.Quick (results())
// end of correct end-token tests
// ==========================================================================================================
// clean text from file returns intended sent.
// end of intended sent. tests
[<Property>]
let ``RequestRandomText returns a string which ends with the correct end-token`` () =
let test () =
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
[<Property>]
let ``RequestText returns a string which ends with the correct end-token`` () =
let test () =
Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends with with the correct end-token when using console-waterwork-announcement`` () =
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends with with the correct end-token when using desktop-clock-info`` () =
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends with with the correct end-token when using test-post`` () =
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends withwith the correct end-token when using word-generator`` () =
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results