Browse Source

Added CleanText command-method.

Help attributes added, as well.
Updated the remainig property tests to make "results" a function and not a value. (E.G. was 'let result =' now 'let result ()=')
The null test in PropertyTests.fs are still commented out.
master
Craig Oates 6 years ago
parent
commit
89d210c057
  1. 36
      TestCentre/PropertyTests.fs
  2. 20
      WetPancakeCLI/ConsoleCommands.cs

36
TestCentre/PropertyTests.fs

@ -116,17 +116,17 @@
let test () =
Pancake.RequestAllTemplateFilesAsync ()
|> Async.RunSynchronously
let results = Assert.NotEmpty (test())
Check.Quick results
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())
Pancake.RequestCleanTextAsync (ValidGibberishLevelInput()) 4
|> Async.RunSynchronously
|> EndsAsIntended
let results () = Assert.True(test())
Check.Quick results
Check.Quick (results())
[<Property>]
let ``RequestCleanText returns intended number of sentences`` () =
@ -135,8 +135,8 @@
Pancake.RequestCleanTextAsync (ValidGibberishLevelInput()) desiredSentencesCount
|> Async.RunSynchronously
|> CountSentences
let results = Assert.Equal(desiredSentencesCount, test())
Check.Quick results
let results () = Assert.Equal(desiredSentencesCount, test())
Check.Quick (results())
[<Property>]
let ``RequestCleanTextFromFile returns a string which ends with the correct end-token when using console-waterworks-announcement`` () =
@ -220,8 +220,8 @@
Pancake.RequestRandomTextAsync ()
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
let results () = Assert.True(test())
Check.Quick (results())
[<Property>]
let ``RequestText returns a string which ends with the correct end-token`` () =
@ -229,8 +229,8 @@
Pancake.RequestTextAsync (ValidGibberishLevelInput()) (ValidSentencesInput())
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
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`` () =
@ -238,8 +238,8 @@
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) ConsoleWaterworks
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
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`` () =
@ -247,8 +247,8 @@
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) DesktopClock
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
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`` () =
@ -256,8 +256,8 @@
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) TestPost
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
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`` () =
@ -265,5 +265,5 @@
Pancake.RequestTextFromFileAsync (ValidGibberishLevelInput()) (ValidSentencesInput()) WordGenerator
|> Async.RunSynchronously
|> EndsAsIntended
let results = Assert.True(test())
Check.Quick results
let results () = Assert.True(test())
Check.Quick (results())

20
WetPancakeCLI/ConsoleCommands.cs

@ -198,10 +198,26 @@ namespace WetPancakeCLI
}
}
// TODO: Write a "clean-test" command-method so the function can be called manually.
[ListCommand]
[Description("Checks to see if the string matches the desired sentence count and removes any over that limit.\n" +
"If the string has less sentences than the number requested, it will not change.\n" +
"Sentences must be greater than 0 and text must contain at least 1 \".\" \"?\" \"!\"")]
[Parameters("sentences: int, text: string")]
[Usage("> CleanText 1 \"This is a test sentence. And, this one needs to be removed.\"")]
public static string CleanText(int sentences, string text)
{
throw new NotImplementedException();
try
{
if (sentences < 1)
throw new ArgumentException ("Invalid argument. Must be greater than 0", "sentences");
return FSharpAsync.StartAsTask
(CleanResultAsync(sentences, text), _taskCreationOptions, _cancellationToken).Result;
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
throw;
}
}
}
}

Loading…
Cancel
Save