|
|
|
@ -5,23 +5,46 @@
|
|
|
|
|
open System |
|
|
|
|
open FsCheck.Xunit |
|
|
|
|
open DeathSocket.Validation |
|
|
|
|
open System.Drawing |
|
|
|
|
|
|
|
|
|
let testingColourArray = |
|
|
|
|
colourList |
|
|
|
|
|> Map.toSeq |
|
|
|
|
|> Seq.map fst |
|
|
|
|
|> Seq.toArray |
|
|
|
|
|
|
|
|
|
let randomColour () = |
|
|
|
|
testingColourArray.[Random().Next(testingColourArray.Length)] |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Setting pen width greater than 0`` () = |
|
|
|
|
let ``Pen width is set greater than 0`` () = |
|
|
|
|
(setPenWidth (Random().Next()) (Random().Next())) > 0.0f |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Parsed colour matches expected colour`` () = |
|
|
|
|
let expectedColour = (randomColour ()) |
|
|
|
|
let brush = parseColour (expectedColour) |
|
|
|
|
let convertedBrush = (brush :?> SolidBrush).Color.Name.ToLower() |
|
|
|
|
convertedBrush = expectedColour |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module UnitTests = |
|
|
|
|
|
|
|
|
|
open Xunit |
|
|
|
|
open DeathSocket.Validation |
|
|
|
|
open System.IO |
|
|
|
|
open DeathSocket.Validation |
|
|
|
|
open Xunit |
|
|
|
|
|
|
|
|
|
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea/" |
|
|
|
|
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea" |
|
|
|
|
|
|
|
|
|
[<Fact>] |
|
|
|
|
let ``Saving Test Area can be located`` () = |
|
|
|
|
Assert.True (Directory.Exists saveLocation) |
|
|
|
|
Assert.True (Directory.Exists (saveLocation)) |
|
|
|
|
|
|
|
|
|
[<Fact>] |
|
|
|
|
let ``Colour list is not empty`` () = |
|
|
|
|
Assert.False (colourList.IsEmpty) |
|
|
|
|
Assert.False (colourList.IsEmpty) |
|
|
|
|
|
|
|
|
|
[<Fact>] |
|
|
|
|
let ``Exception thrown when invalid colour is used`` () = |
|
|
|
|
Assert.Throws<System.ArgumentException> |
|
|
|
|
(fun () -> parseColour "not a valid colour" |> ignore) |