Browse Source

Merge pull request #8 from CraigOates/0.6-p1

0.6 p1
master
Craig Oates 6 years ago committed by GitHub
parent
commit
8983653f64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      TestCentre/InputGeneration.fs
  2. 172
      TestCentre/PropertyTests.fs
  3. 17
      TestCentre/TestCentre.fsproj
  4. 6
      TestCentre/TestingConstants.fs
  5. 21
      TestCentre/TextFiles/desktop-clock-info.txt
  6. 4
      TestCentre/TextFiles/test-post.txt
  7. 85
      TestCentre/UnitTests.fs
  8. 2
      TestCentre/packages.config
  9. 21
      WetPancake/DataProcessing.fs
  10. 7
      WetPancake/DataServices.fs
  11. 61
      WetPancake/ProductServices.fs
  12. 69
      WetPancake/Script.fsx
  13. 10
      WetPancake/TextFiles/desktop-clock-info.txt
  14. 4
      WetPancake/TextFiles/test-post.txt
  15. 16
      WetPancake/WetPancake.fsproj
  16. 59
      WetPancakeCLI/ConsoleCommands.cs

23
TestCentre/InputGeneration.fs

@ -0,0 +1,23 @@
module InputGeneration
open System
open TestingConstants
let ValidGibberishLevelInput () =
let testInputs = [|2 .. 20|]
let index = Random().Next(0, testInputs.Length)
testInputs.[index]
let ValidSentencesInput () = System.Random().Next(2, 10)
let InvalidGibberishLevelInput () =
let testInputs = Array.concat [ [|0; 1|] ; [|21 .. 100|] ]
let index = System.Random().Next(0, testInputs.Length)
testInputs.[index]
let InvalidSentencesInput () = System.Random().Next(-5, 1)
let ValidFileInput () =
let testInputs = [|ConsoleWaterworks; DesktopClock; TestPost; WordGenerator|]
let index = Random().Next(0, testInputs.Length)
testInputs.[index]

172
TestCentre/PropertyTests.fs

@ -6,11 +6,13 @@
open WetPancake
open TestingConstants
open System.Diagnostics
open System
open InputGeneration
module ``Null Tests`` =
[<Property>]
let ``Request Random Text does not return null when using the built-in random settings`` () =
let ``Request Random Text does not return a null when using the built-in random settings`` () =
let test =
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
@ -18,188 +20,172 @@
Check.Quick results
[<Property>]
let ``Request Text does not return null when using fixed input parameters`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextAsync (gibberishLevel()) (totalSentences())
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
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``Request Text does not return null when using a random gibberish level`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextAsync (gibberishLevel()) 10
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 ``Request Text does not return null when using a random sentence count`` () =
let totalSentences () = System.Random().Next(2, 10)
let ``RequestTextFromFile does not return a null when using console-waterworks-info`` () =
let test () =
Pancake.RequestTextAsync 5 (totalSentences())
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
let results () = Assert.NotNull test
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``Using desktop-clock-info does not return null`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) DesktopClock
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
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``Using console-waterworks-announcement does not return null`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) ConsoleWaterworks
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
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``Using word-generator does not return null`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) WordGenerator
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
let results = Assert.NotNull (test())
Check.Quick results
[<Property>]
let ``Using test-post does not return null`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) TestPost
let ``RequestAllTemplateFiles does not return a null`` () =
let test () =
Pancake.RequestAllTemplateFilesAsync ()
|> Async.RunSynchronously
let results = Assert.NotNull test
let results = Assert.NotNull (test())
Check.Quick results
module ``Contents Test`` =
[<Property>]
let ``RequestRandomText returns a string which contains a full stop`` () =
let test =
let test () =
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
let results = Assert.Contains(".", test)
let results = Assert.Contains(".", test())
Check.Quick results
[<Property>]
let ``RequestText returns a string which contains a full stop`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextAsync (gibberishLevel()) (totalSentences())
let test () =
Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
let results = Assert.Contains(".", test)
let results = Assert.Contains(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which contains a full stop when using console-waterworks-announcement`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) ConsoleWaterworks
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
let results = Assert.Contains(".", test)
let results = Assert.Contains(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which contains a full stop when using desktop-clock-info`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) DesktopClock
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
let results = Assert.Contains(".", test)
let results = Assert.Contains(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which contains a full stop when using test-post`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) TestPost
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
let results = Assert.Contains(".", test)
let results = Assert.Contains(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which contains a full stop when using word-generator`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) WordGenerator
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
let results = Assert.Contains(".", test)
let results = Assert.Contains(".", test())
Check.Quick results
[<Property>]
let ``RequestRandomText returns a string which ends with a full stop`` () =
let test =
let test () =
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
let results = Assert.EndsWith(".", test)
let results = Assert.EndsWith(".", test())
Check.Quick results
[<Property>]
let ``RequestTest returns a string which ends with a full stop`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextAsync (gibberishLevel()) (totalSentences())
let test () =
Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
let results = Assert.EndsWith(".", test)
let results = Assert.EndsWith(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends with a full stop when using console-waterwork-announcement`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) ConsoleWaterworks
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
let results = Assert.EndsWith(".", test)
let results = Assert.EndsWith(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends with a full stop when using desktop-clock-info`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) DesktopClock
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
let results = Assert.EndsWith(".", test)
let results = Assert.EndsWith(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends with a full stop when using test-post`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) TestPost
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
let results = Assert.EndsWith(".", test)
let results = Assert.EndsWith(".", test())
Check.Quick results
[<Property>]
let ``RequestTextFromFile returns a string which ends with a full stop when using word-generator`` () =
let gibberishLevel () = System.Random().Next(2, 10)
let totalSentences () = System.Random().Next(2, 10)
let test =
Pancake.RequestTextFromFileAsync (gibberishLevel()) (totalSentences()) WordGenerator
let test () =
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
let results = Assert.EndsWith(".", test)
let results = Assert.EndsWith(".", 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

17
TestCentre/TestCentre.fsproj

@ -55,16 +55,25 @@
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<ItemGroup>
<Content Include="TextFiles\desktop-clock-info.txt" />
<Content Include="TextFiles\console-waterworks-announcement.txt" />
<Content Include="TextFiles\word-generator.txt" />
<Content Include="TextFiles\test-post.txt" />
<Compile Include="AssemblyInfo.fs" />
<Compile Include="TestingConstants.fs" />
<Compile Include="InputGeneration.fs" />
<Compile Include="UnitTests.fs" />
<Compile Include="PropertyTests.fs" />
<None Include="Script.fsx" />
<Content Include="packages.config" />
<Content Include="TextFiles\console-waterworks-announcement.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TextFiles\word-generator.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TextFiles\test-post.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TextFiles\desktop-clock-info.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="FsCheck">

6
TestCentre/TestingConstants.fs

@ -13,3 +13,9 @@ let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt"
[<Literal>]
let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt"
[<Literal>]
let InvalidFilePathInput = __SOURCE_DIRECTORY__ + @"Invalid/file.txt"
[<Literal>]
let InvalidFileTypeInput = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.doc"

21
TestCentre/TextFiles/desktop-clock-info.txt

@ -1,14 +1,17 @@
About Desktop Clock
This is a basic WPF program which displays the data and time so it is readable from a distance.
Desktop Clock uses a NuGet package called This allows the program to look like a Windows 10 UWP program.
The most notable aspects being the translucent chrome and the highlighting of near-by buttons.
Screenshot 1 Desktop Clock is a WPF program which looks like a UWP program.
This is a basic WPF program which displays the data and time so it is readable from a distance. Desktop Clock uses a NuGet package called This allows the program to look like a Windows 10 UWP program. The most notable aspects being the translucent chrome and the highlighting of near-by buttons.
Screenshot 1 Desktop Clock is a WPF program which looks like a UWP program.Publishing Information
If you would like to use, it you will need to build from the source code provided. I did not want to mess around with ClickOnce or any other packaging mechanism.
If you would like to use, it you will need to build from the source code provided.
I did not want to mess around with ClickOnce or any other packaging mechanism.
With it being a WPF program, it can run on Windows 7 and 8 machines.
Future Plans
I do not intend to take this any further. It is a simple program which I have running 247, floating about on the screen. It sits there and does what I need it to do. Anything else seems like overkill and I do not find myself wanting it to do something extra. Therefore, if you want something adding to it, I recommend you fork it.
GitHub
I do not intend to take this any further.
It is a simple program which I have running 247, floating about on the screen.
It sits there and does what I need it to do.
Anything else seems like overkill and I do not find myself wanting it to do something extra.
Therefore, if you want something adding to it, I recommend you fork it.
Desktop Clock is  available on GitHub. Feel free to check it out, download it or fork it
Desktop Clock is available on GitHub. Feel free to check it out, download it or fork it.

4
TestCentre/TextFiles/test-post.txt

@ -8,6 +8,4 @@ Wow, you really are sticking around, aren't you? Hmm... okay... I guess I should
Let me begin by offering you a sincere "Hello and how are you today?" I hope the weather is nice when and where you are. There is something about it which can make or break a day. The tussle between working with and against it can leave a mark on the soul. But, there is a certain type of comfort to be had when you acknowledge it will always win against the human race. Jammy dodger? Would you like sugar in your tea?
Is that the doorbell? Excuse me, I'm just going to see whom it is -- or is it who?
...
Is that the doorbell? Excuse me, I'm just going to see whom it is -- or is it who?

85
TestCentre/UnitTests.fs

@ -4,6 +4,7 @@
open WetPancake
open TestingConstants
open System.IO
open InputGeneration
module ``File Access Tests`` =
@ -37,40 +38,35 @@
let ``RequestRandomText does not return a null`` () =
let result = Pancake.RequestRandomTextAsync ()
Assert.NotNull result
[<Fact>]
let ``RequestText does not return a null`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result () = Pancake.RequestTextAsync gibberishLevel totalSentences
let result () = Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
Assert.NotNull result
[<Fact>]
let ``RequestTextFromFile does not return a null when using desktop-clock-info`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result = Pancake.RequestTextFromFileAsync gibberishLevel totalSentences DesktopClock
let result = Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
Assert.NotNull result
[<Fact>]
let ``RequestTextFromFile does not return a null when using console-waterworks-announcement`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result = Pancake.RequestTextFromFileAsync gibberishLevel totalSentences ConsoleWaterworks
let result = Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
Assert.NotNull result
[<Fact>]
let ``RequestTextFromFile does not return a null when using word-generator`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result = Pancake.RequestTextFromFileAsync gibberishLevel totalSentences WordGenerator
let result = Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
Assert.NotNull result
[<Fact>]
let ``RequestTestFromFile does not generate a null when using test-post`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result = Pancake.RequestTextFromFileAsync gibberishLevel totalSentences TestPost
let result = Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
Assert.NotNull result
[<Fact>]
let ``RequestAllTemplateFiles does not generate a null`` () =
let result = Pancake.RequestAllTemplateFilesAsync ()
Assert.NotNull result
module ``Contents Tests`` =
@ -84,46 +80,36 @@
[<Fact>]
let ``RequestText returns a string which contains a full stop`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextAsync gibberishLevel totalSentences
Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
Assert.Contains(".", result)
[<Fact>]
let ``RequestTextFromFile returns a string which contains a full stop when using console-waterworks-announcement`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences ConsoleWaterworks
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
Assert.Contains(".", result)
[<Fact>]
let ``RequestTextFromFile returns a string which contains a full stop when using desktop-clock-info`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences DesktopClock
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
Assert.Contains(".", result)
[<Fact>]
let ``RequestTextFromFile returns a string which contains a full stop when using test-post`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences TestPost
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
Assert.Contains(".", result)
[<Fact>]
let ``RequestTextFromFile returns a string which contains a full stop when using word-generator`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences WordGenerator
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
Assert.Contains(".", result)
@ -136,45 +122,42 @@
[<Fact>]
let ``RequestText returns a string which ends with a full stop`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextAsync gibberishLevel totalSentences
Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
Assert.EndsWith(".", result)
[<Fact>]
let ``RequestTextFromFile returns a string which ends with a full stop when using console-waterworks-announcement`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences ConsoleWaterworks
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
Assert.EndsWith(".", result)
[<Fact>]
let ``RequestTextFromFile returns a sting which ends with a full stop when using desktop-clock-info`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences DesktopClock
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
Assert.EndsWith(".", result)
[<Fact>]
let ``RequestTextFromFile returns a sting which ends with a full stop when using test-post`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences TestPost
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
Assert.EndsWith(".", result)
[<Fact>]
let ``RequestTextFromFile returns a sting which ends with a full stop when using word-generator`` () =
let gibberishLevel = System.Random().Next(2, 20)
let totalSentences = System.Random().Next(2, 20)
let result =
Pancake.RequestTextFromFileAsync gibberishLevel totalSentences WordGenerator
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
Assert.EndsWith(".", result)
[<Fact>]
let ``RequestAllTemplateFiles does not return an empty list`` () =
let result =
Pancake.RequestAllTemplateFilesAsync ()
|> Async.RunSynchronously
Assert.EndsWith(".", result)
Assert.NotEmpty result

2
TestCentre/packages.config

@ -6,7 +6,7 @@
<package id="System.ValueTuple" version="4.5.0" targetFramework="net471" />
<package id="xunit" version="2.3.1" targetFramework="net471" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net471" />
<package id="xunit.analyzers" version="0.9.0" targetFramework="net471" />
<package id="xunit.analyzers" version="0.10.0" targetFramework="net471" />
<package id="xunit.assert" version="2.3.1" targetFramework="net471" />
<package id="xunit.core" version="2.3.1" targetFramework="net471" />
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net471" />

21
WetPancake/DataProcessing.fs

@ -3,11 +3,32 @@
open System.Text.RegularExpressions
open DataCleaning
open System
open System.IO
let MatchText pattern text = Regex.IsMatch(text, pattern)
let ConcatToString words = String.concat " " words
let GibberishLevelIsValid gibberishLevel =
match gibberishLevel with
| gibberishLevel when gibberishLevel < 2 || gibberishLevel > 20 ->
raise (new ArgumentException("Invalid argument. Must be between 2 and 20 (inclusive).", "gibberishLevel"))
| _ -> ignore
let SentencesIsValid sentences =
match sentences with
| sentences when sentences < 1 ->
raise (ArgumentException("Invalid argument. Must be greater than 0.", "sentences"))
| _ -> ignore
let FilePathIsValid filePath =
match filePath with
| filePath when Path.GetExtension filePath <> ".txt" ->
raise (ArgumentException("Invalid argument. File must be a .txt file.","filePath"))
| filePath when not (File.Exists filePath) ->
raise (ArgumentException("Invalid argument. File must include a valid file path.","filePath"))
| _ -> ignore
let SortIntoGroups groupSize text =
SplitText @"\s+" text // Splits text where there is a space.
|> Seq.windowed groupSize

7
WetPancake/DataServices.fs

@ -6,11 +6,16 @@
open DataCleaning
open System.Threading
open System
open DataAccess
let CheckFileExists filePath =
ListSampleFiles
|> Array.contains filePath
let rec GenerateMarkovChain (map: Map<string, string List>) (state:string) chain =
if map.ContainsKey state then
let nextChoice = map.[state] |> PickRandomItem
if MatchText @"\." nextChoice then nextChoice :: chain
if MatchText @"$\." nextChoice then nextChoice :: chain
else
let currentWords =
state

61
WetPancake/ProductServices.fs

@ -1,5 +1,7 @@
namespace WetPancake
open System.Linq.Expressions
module Pancake =
open SystemServices
@ -7,6 +9,7 @@ module Pancake =
open DataProcessing
open DataStructuring
open DataServices
open System
let RequestRandomTextAsync() =
async {
@ -16,37 +19,45 @@ module Pancake =
|> SortIntoGroups (PickRandomNumber 2 10)
|> GenerateMap
return GenerateMarkovText (PickRandomNumber 2 10) data
}
}
let RequestTextAsync (gibberishLevel: int) (sentences: int) =
async {
let data =
LoadFile (SelectRandomSampleFile())
|> ApplyStandardSetup
|> SortIntoGroups gibberishLevel
|> GenerateMap
return GenerateMarkovText sentences data
try
GibberishLevelIsValid gibberishLevel |> ignore
SentencesIsValid sentences |> ignore
let data =
LoadFile (SelectRandomSampleFile())
|> ApplyStandardSetup
|> SortIntoGroups gibberishLevel
|> GenerateMap
return GenerateMarkovText sentences data
with
| :? ArgumentException as ex ->
return ex.Message
}
let RequestTextFromFileAsync (gibberishLevel: int) (sentences: int) (filePath: string) =
async {
let data =
LoadFile filePath
|> ApplyStandardSetup
|> SortIntoGroups gibberishLevel
|> GenerateMap
return GenerateMarkovText sentences data
try
GibberishLevelIsValid gibberishLevel |> ignore
SentencesIsValid sentences |> ignore
FilePathIsValid |> ignore
let data =
LoadFile filePath
|> ApplyStandardSetup
|> SortIntoGroups gibberishLevel
|> GenerateMap
return GenerateMarkovText sentences data
with
| :? ArgumentException as ex ->
return ex.Message
}
// Add Checks to make sure the client is passing in a .txt file?
// Leave for the client to check?
// Give the client a function to check (and throw) if not handed a .txt file?
(* Should the library provide list of the available default txt files?
By doing so, the user can specify a particular file from the list available.
Is this overkill?
Command-method Example
======================
public static string RetrieveAllTxtFiles()...
public static string GenerateTextFromDefault(gibberishLevel, sentences, defaultFileName)... *)
let RequestAllTemplateFilesAsync () =
async {
let files =
ListSampleFiles
|> Array.toList
return files
}

69
WetPancake/Script.fsx

@ -16,6 +16,17 @@ open DataProcessing
open DataStructuring
open DataServices
open WetPancake
open System
// Template Files
[<Literal>]
let DesktopClock = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.txt"
[<Literal>]
let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt"
[<Literal>]
let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt"
[<Literal>]
let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt"
// System Services
let ss_number = PickRandomNumber 10
@ -79,6 +90,27 @@ let dp_combine4 =
let prev = "Next is null"
let next = null
CombineWords prev next
let dp_gibberishException =
try
GibberishLevelIsValid 0 // enter a number here
|> ignore
"No exception thrown"
with :? ArgumentException as ex -> ex.Message
let dp_sentencesException =
try
SentencesIsValid 0 // enter a number here
|> ignore
"No exception thrown"
with :? ArgumentException as ex -> ex.Message
let dp_filePathIsValidException =
let invalidPath = "C:/notvalid/test.txt"
let invalidFileType = "C:/notvalid/test.doc"
// Template file paths by the open & load declarations
try
FilePathIsValid TestPost // enter filepath here
|> ignore
"No exception thrown"
with :? ArgumentException as ex -> ex.Message
// Data Structuring
let ds_map = Map.empty
@ -121,26 +153,19 @@ let dss_sentences = GenerateMarkovText 2 dss_text
printfn "Text: %A" dss_sentences
// (WetPancake) Pancake
[<Literal>]
let DesktopClock = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.txt"
[<Literal>]
let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt"
[<Literal>]
let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt"
[<Literal>]
let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt"
let p_result = Pancake.RequestRandomTextAsync()
let p_result2 = Pancake.RequestTextAsync 5 10
let p_result3 = Pancake.RequestTextFromFileAsync 3 10 DesktopClock
let p_result4 = Pancake.RequestTextFromFileAsync 3 10 ConsoleWaterworks
let p_result5 = Pancake.RequestTextFromFileAsync 3 10 WordGenerator
let p_result6 = Pancake.RequestTextFromFileAsync 3 10 TestPost
// Product Services (Pancake)
let ps_result1 = Pancake.RequestRandomTextAsync()
let ps_result2 = Pancake.RequestTextAsync 5 10
let ps_result3 = Pancake.RequestTextFromFileAsync 3 10 DesktopClock
let ps_result4 = Pancake.RequestTextFromFileAsync 3 10 ConsoleWaterworks
let ps_result5 = Pancake.RequestTextFromFileAsync 3 10 WordGenerator
let ps_result6 = Pancake.RequestTextFromFileAsync 3 10 TestPost
let ps_files = Pancake.RequestAllTemplateFilesAsync ()
p_result |> Async.RunSynchronously
p_result2 |> Async.RunSynchronously
p_result3 |> Async.RunSynchronously
p_result4 |> Async.RunSynchronously
p_result5 |> Async.RunSynchronously
p_result6 |> Async.RunSynchronously
ps_result1 |> Async.RunSynchronously
ps_result2 |> Async.RunSynchronously
ps_result3 |> Async.RunSynchronously
ps_result4 |> Async.RunSynchronously
ps_result5 |> Async.RunSynchronously
ps_result6 |> Async.RunSynchronously
ps_files |> Async.RunSynchronously

10
WetPancake/TextFiles/desktop-clock-info.txt

@ -1,14 +1,10 @@
About Desktop Clock
This is a basic WPF program which displays the data and time so it is readable from a distance. Desktop Clock uses a NuGet package called This allows the program to look like a Windows 10 UWP program. The most notable aspects being the translucent chrome and the highlighting of near-by buttons.
Screenshot 1 Desktop Clock is a WPF program which looks like a UWP program.Publishing Information
This is a basic WPF program which displays the data and time so it is readable from a distance. Desktop Clock uses a NuGet package called This allows the program to look like a Windows 10 UWP program. The most notable aspects being the translucent chrome and the highlighting of near-by buttons.
Screenshot 1 Desktop Clock is a WPF program which looks like a UWP program.
If you would like to use, it you will need to build from the source code provided. I did not want to mess around with ClickOnce or any other packaging mechanism.
With it being a WPF program, it can run on Windows 7 and 8 machines.
Future Plans
I do not intend to take this any further. It is a simple program which I have running 247, floating about on the screen. It sits there and does what I need it to do. Anything else seems like overkill and I do not find myself wanting it to do something extra. Therefore, if you want something adding to it, I recommend you fork it.
GitHub
Desktop Clock is  available on GitHub. Feel free to check it out, download it or fork it
Desktop Clock is  available on GitHub. Feel free to check it out, download it or fork it.

4
WetPancake/TextFiles/test-post.txt

@ -8,6 +8,4 @@ Wow, you really are sticking around, aren't you? Hmm... okay... I guess I should
Let me begin by offering you a sincere "Hello and how are you today?" I hope the weather is nice when and where you are. There is something about it which can make or break a day. The tussle between working with and against it can leave a mark on the soul. But, there is a certain type of comfort to be had when you acknowledge it will always win against the human race. Jammy dodger? Would you like sugar in your tea?
Is that the doorbell? Excuse me, I'm just going to see whom it is -- or is it who?
...
Is that the doorbell? Excuse me, I'm just going to see whom it is -- or is it who?

16
WetPancake/WetPancake.fsproj

@ -51,10 +51,18 @@
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<ItemGroup>
<Content Include="TextFiles\desktop-clock-info.txt" />
<Content Include="TextFiles\console-waterworks-announcement.txt" />
<Content Include="TextFiles\word-generator.txt" />
<Content Include="TextFiles\test-post.txt" />
<Content Include="TextFiles\desktop-clock-info.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TextFiles\console-waterworks-announcement.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TextFiles\word-generator.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TextFiles\test-post.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="SystemServices.fs" />
<Compile Include="DataAccess.fs" />

59
WetPancakeCLI/ConsoleCommands.cs

@ -8,6 +8,8 @@ using System.Threading.Tasks;
using Microsoft.FSharp.Control;
using Microsoft.FSharp.Core;
using System.Threading;
using System.IO;
using static System.Console;
namespace WetPancakeCLI
{
@ -42,48 +44,73 @@ namespace WetPancakeCLI
[Usage("> GenerateRandomText")]
public static string GenerateRandomText()
{
string result = String.Empty;
try { return FSharpAsync.StartAsTask(RequestRandomTextAsync(), _taskCreationOptions, _cancellationToken).Result; }
catch (Exception e)
{
Debug.WriteLine(e.Message);
System.Console.WriteLine("[ERROR] Unable to complete request. Re-executing command...");
return FSharpAsync.StartAsTask(RequestRandomTextAsync(), _taskCreationOptions, _cancellationToken).Result;
throw;
}
}
[ListCommand]
[Description("Generates text using the gibberish level and number of sentences specified by the user. Gibberish level must be greater the 1.")]
[Description("Generates text using the gibberish level and number of sentences specified by the user. Gibberish level must be between 2 and 20.")]
[Parameters("gibberish level: int, sentences: int")]
[Usage("> GenerateText 5 10")]
public static string GenerateText(int gibberishLevel, int sentences)
{
if (gibberishLevel < 2) return "Please enter a gibberish level greater than 1.";
try { return FSharpAsync.StartAsTask(RequestTextAsync(gibberishLevel, sentences), _taskCreationOptions, _cancellationToken).Result; }
try
{
if (gibberishLevel < 2 || gibberishLevel > 20) throw new ArgumentException("Invalid argument. Must be between 2 and 20 (inclusive).", "gibberishLevel");
if (sentences < 1) throw new ArgumentException("Invalid argument. Must be greater than 0.", "sentences");
return FSharpAsync.StartAsTask(RequestTextAsync(gibberishLevel, sentences), _taskCreationOptions, _cancellationToken).Result;
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
System.Console.WriteLine("[ERROR] Unable to complete request. Re-executing command...");
return FSharpAsync.StartAsTask(RequestTextAsync(gibberishLevel, sentences), _taskCreationOptions, _cancellationToken).Result;
throw;
}
}
// YOU ARE WORKING IN HERE... (0.5-P1)
[ListCommand]
[Description("Loads the specified .txt file and generates text based on it using the gibberish level and number of sentences specified by the user. Gibberish level must be greater the 1.")]
[Description("Loads the specified .txt file and generates text based on it using the gibberish level and number of sentences specified by the user. Gibberish level must be between 2 and 20.")]
[Parameters("gibberish level: int, sentences: int, file path: string")]
[Usage("> RequestTextFromFile 3 6 C:/yourfile.txt")]
[Usage("> GenerateTextFromFile 3 6 C:/yourfile.txt")]
public static string GenerateTextFromFile(int gibberishLevel, int sentences, string filePath)
{
// Could do with checking if the file type is .txt...
if (gibberishLevel < 2) return "Please enter a gibberish level greater than 1.";
try
{ return FSharpAsync.StartAsTask(RequestTextFromFileAsync(gibberishLevel, sentences, filePath), _taskCreationOptions, _cancellationToken).Result; }
{
if (gibberishLevel < 2 || gibberishLevel > 20) throw new ArgumentException("Invalid argument. Must be between 2 and 20 (inclusive).", "gibberishLevel");
if (sentences < 1) throw new ArgumentException("Invalid argument. Must be greater than 0.", "sentences");
if (Path.GetExtension(filePath) != ".txt") throw new FileLoadException("The file entered is not a plain text (.txt) file.", filePath);
return FSharpAsync.StartAsTask(RequestTextFromFileAsync(gibberishLevel, sentences, filePath), _taskCreationOptions, _cancellationToken).Result;
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
System.Console.WriteLine("[ERROR] Unable to complete request. Re-executing command...");
return FSharpAsync.StartAsTask(RequestTextFromFileAsync(gibberishLevel, sentences, filePath), _taskCreationOptions, _cancellationToken).Result;
throw;
}
}
[ListCommand]
[Description("Returns a list of all the available .txt files built-in to Wet Pancake.")]
[Parameters("None")]
[Usage("> RequestAllTemplateFiles")]
public static string RequestAllTemplateFiles()
{
try
{
WriteLine("Attempting to list out the available template files...");
var files = FSharpAsync.StartAsTask(RequestAllTemplateFilesAsync(), _taskCreationOptions, _cancellationToken).Result;
foreach (var item in files)
{
WriteLine($"File path: {item}");
}
return "Listing complete.";
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
throw;
}
}
}

Loading…
Cancel
Save