Browse Source

Refactor RequestAllTemplateFiles and quick-guide.pdf.

master
Craig Oates 6 years ago
parent
commit
773c973038
  1. 2
      TestCentre/PropertyTests.fs
  2. 4
      TestCentre/UnitTests.fs
  3. 10
      WetPancake/ProductServices.fs
  4. 11
      WetPancakeCLI/ConsoleCommands.cs
  5. BIN
      WetPancakeCLI/ProductInfo/quick-guide.pdf

2
TestCentre/PropertyTests.fs

@ -33,7 +33,7 @@
[<Property>] [<Property>]
let ``RequestAllTemplateFiles does not return an empty list`` () = let ``RequestAllTemplateFiles does not return an empty list`` () =
let test () = let test () =
Pancake.RequestAllTemplateFilesAsync () Pancake.RequestAllTemplateFiles ()
|> Async.RunSynchronously |> Async.RunSynchronously
let results () = Assert.NotEmpty (test()) let results () = Assert.NotEmpty (test())
Check.Quick (results()) Check.Quick (results())

4
TestCentre/UnitTests.fs

@ -49,7 +49,7 @@
[<Fact>] [<Fact>]
let ``RequestAllTemplateFiles does not generate a null`` () = let ``RequestAllTemplateFiles does not generate a null`` () =
let result = Pancake.RequestAllTemplateFilesAsync () let result = Pancake.RequestAllTemplateFiles ()
Assert.NotNull result Assert.NotNull result
[<Fact>] [<Fact>]
@ -142,7 +142,7 @@
[<Fact>] [<Fact>]
let ``RequestAllTemplateFiles does not return an empty list`` () = let ``RequestAllTemplateFiles does not return an empty list`` () =
let result = let result =
Pancake.RequestAllTemplateFilesAsync () Pancake.RequestAllTemplateFiles ()
|> Async.RunSynchronously |> Async.RunSynchronously
Assert.NotEmpty result Assert.NotEmpty result

10
WetPancake/ProductServices.fs

@ -189,13 +189,9 @@ module Pancake =
/// You can use the information provided by this function alongside the "RequestTextFromFileAsync” function. /// You can use the information provided by this function alongside the "RequestTextFromFileAsync” function.
/// This allows you to generate text using one of the built-in template (.txt) files. /// This allows you to generate text using one of the built-in template (.txt) files.
/// </remarks> /// </remarks>
let RequestAllTemplateFilesAsync () = let RequestAllTemplateFiles () =
async { ListSampleFiles
let files = |> Array.toList
ListSampleFiles
|> Array.toList
return files
}
/// <summary> /// <summary>
/// An asynchronous function which generates random text. /// An asynchronous function which generates random text.

11
WetPancakeCLI/ConsoleCommands.cs

@ -56,16 +56,16 @@ namespace WetPancakeCLI
if (string.IsNullOrWhiteSpace(filePath)) if (string.IsNullOrWhiteSpace(filePath))
{ {
var desktopDirectory = GetFolderPath(SpecialFolder.Desktop); var desktopDirectory = GetFolderPath(SpecialFolder.Desktop);
var savePath = $"{desktopDirectory}\\wet-pankcake-cheatsheet.pdf"; var savePath = $"{desktopDirectory}\\wet-pancake-quick-guide.pdf";
File.Copy(cheatsheetPath, savePath, true); File.Copy(cheatsheetPath, savePath, true);
return "Quick Guide written to desktop."; return "Quick Guide written to desktop.";
} }
else else
{ {
var customSavePath = $"{filePath}\\wet-pankcake-cheatsheet.pdf"; var customSavePath = $"{filePath}\\wet-pancake-quick-guide.pdf";
File.Copy(cheatsheetPath, customSavePath, true); File.Copy(cheatsheetPath, customSavePath, true);
if (!Directory.Exists(filePath)) throw new DirectoryNotFoundException(); if (!Directory.Exists(filePath)) throw new DirectoryNotFoundException();
return $"Quick Guide added to {filePath}"; return $"Quick Guide written to {filePath}";
} }
} }
@ -116,10 +116,7 @@ namespace WetPancakeCLI
try try
{ {
WriteLine("Attempting to list out the available template files..."); WriteLine("Attempting to list out the available template files...");
var files = foreach (var item in RequestAllTemplateFiles())
FSharpAsync.StartAsTask
(RequestAllTemplateFilesAsync(), _taskCreationOptions, _cancellationToken).Result;
foreach (var item in files)
{ {
WriteLine($"File path: {item}"); WriteLine($"File path: {item}");
} }

BIN
WetPancakeCLI/ProductInfo/quick-guide.pdf

Binary file not shown.
Loading…
Cancel
Save