|
|
|
@ -21,9 +21,12 @@
|
|
|
|
|
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.*) |
|
|
|
|
ConsoleTests.fs. *) |
|
|
|
|
let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea" |
|
|
|
|
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea" |
|
|
|
|
|
|
|
|
@ -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)] |
|
|
|
|
|
|
|
|
@ -51,7 +58,7 @@
|
|
|
|
|
saveLocation + "/" + fileName |
|
|
|
|
|
|
|
|
|
(* To "manually" clear out the SavingTestArea folder, use this function |
|
|
|
|
in script.fsx. More information can be found there, also.*) |
|
|
|
|
in script.fsx. More information can be found there, also. *) |
|
|
|
|
let resetSavingTestArea () = |
|
|
|
|
let files = Directory.GetFileSystemEntries(saveLocation, "*.png") |
|
|
|
|
match files.Length with |
|
|
|
@ -68,13 +75,14 @@
|
|
|
|
|
open DeathSocket.GridPainter |
|
|
|
|
open TestingHelpers |
|
|
|
|
open System.IO |
|
|
|
|
open System |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Can apply grid to image and save it`` () = |
|
|
|
|
(* You should end up with one image left over in SavingTestArea. |
|
|
|
|
Comment out the "reset" function to see all the images produced, |
|
|
|
|
by this test. This will mean you will need to manually delete the |
|
|
|
|
images yourself if you do.*) |
|
|
|
|
images yourself if you do. *) |
|
|
|
|
resetSavingTestArea () |
|
|
|
|
let oPath = generateLoadPath () |
|
|
|
|
let sPath = generateSavePath oPath |
|
|
|
@ -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 |
|
|
|
|