From 3dcb9aaf30e0a5d10899f8a4ef08a410c219ba09 Mon Sep 17 00:00:00 2001 From: "OPTIMUS-PRIME\\craig" Date: Wed, 25 Jul 2018 22:50:18 +0100 Subject: [PATCH] Wrote content test in property tests. RequestCleanTextFromFile ends with correct end-token. Includes console-waterworks, desktop-clock, test-post and word-generator. --- TestCentre/Helpers.fs | 10 +++++++- TestCentre/PropertyTests.fs | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/TestCentre/Helpers.fs b/TestCentre/Helpers.fs index 56a4939..50f6136 100644 --- a/TestCentre/Helpers.fs +++ b/TestCentre/Helpers.fs @@ -1,6 +1,7 @@ module Helpers open System.Text.RegularExpressions + open System // 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). @@ -17,4 +18,11 @@ | '!' -> true | '?' -> true | _ -> false - \ No newline at end of file + + + let RandomBool () = + let x = Random().Next(100) + match x with + | x when x % 2 <> 0 -> false + | x when x % 2 = 0 -> true + | _ -> failwith "Unable to generate a random bool." \ No newline at end of file diff --git a/TestCentre/PropertyTests.fs b/TestCentre/PropertyTests.fs index b5e4df9..ec38981 100644 --- a/TestCentre/PropertyTests.fs +++ b/TestCentre/PropertyTests.fs @@ -140,6 +140,52 @@ let results = Assert.Equal(desiredSentencesCount, test()) Check.Quick results + // clean text from file ends with correct end-token + + [] + 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()) + + [] + 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()) + + [] + 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()) + + [] + 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 + [] let ``RequestRandomText returns a string which ends with the correct end-token`` () = let test () =