Browse Source

add property tests for vertical and horizontal line functions in lib.

master
Craig Oates 6 years ago
parent
commit
a531d98454
  1. 2
      DeathSocket/GridPainter.fs
  2. 22
      TestCentre/LibraryTests.fs

2
DeathSocket/GridPainter.fs

@ -19,11 +19,9 @@ namespace DeathSocket
}
// Needs XML comments.
// Tests have not been written.
let determineHorizontalLines width height rows =
createHorizontalLines width height rows
// Needs XML comments.
// Tests have not been written.
let determineVerticalLines width height columns =
createVerticalLines width height columns

22
TestCentre/LibraryTests.fs

@ -21,6 +21,9 @@
open System.Reflection
open System.IO
let rand = Random ()
(* These are duplicates from ConsoleTests.fs (both of them). See point
about helpers. Tests for checking these locations can be found in
ConsoleTests.fs. *)
@ -35,14 +38,18 @@
|> Seq.toArray
let randomBrush () =
let item = allColours.[Random().Next(allColours.Length)]
let item = allColours.[rand.Next(allColours.Length)]
item.GetValue(null, null)
(* Max. value is arbitrary (change for performance).
Min. value is to stop divide by zero exceptions.
Intended for horizontal and vertical line tests. *)
let newNum () = rand.Next(1, 1000)
let imagesInLoadingTestArea =
Directory.GetFileSystemEntries (loadLocation, "*.png")
let generateLoadPath () =
let rand = Random ()
let files = imagesInLoadingTestArea
files.[rand.Next(files.Length)]
@ -68,6 +75,7 @@
open DeathSocket.GridPainter
open TestingHelpers
open System.IO
open System
[<Property>]
let ``Can apply grid to image and save it`` () =
@ -89,6 +97,16 @@
|> Async.RunSynchronously
(File.Exists sPath) = true
[<Property>]
let ``Can return a collection of points which represent a grids horizontal lines`` () =
let result = determineHorizontalLines (newNum()) (newNum()) (newNum())
result.Length > 0
[<Property>]
let ``Can return a collection of points which represent a grids vertical lines`` () =
let result = determineVerticalLines (newNum()) (newNum()) (newNum())
result.Length > 0
module UnitTests =
open TestingHelpers

Loading…
Cancel
Save