|
|
|
@ -5,10 +5,10 @@
|
|
|
|
|
open System |
|
|
|
|
open System.Drawing |
|
|
|
|
open System.Reflection |
|
|
|
|
open SmoulderingBeachBall.Domain |
|
|
|
|
open SmoulderingBeachBall.Services |
|
|
|
|
open System.IO |
|
|
|
|
|
|
|
|
|
let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea" |
|
|
|
|
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea" |
|
|
|
|
|
|
|
|
|
let allColours = |
|
|
|
|
let properties = |
|
|
|
@ -20,24 +20,18 @@
|
|
|
|
|
let item = allColours.[Random().Next(allColours.Length)] |
|
|
|
|
item.GetValue(null, null) |
|
|
|
|
|
|
|
|
|
let populateSpec () = |
|
|
|
|
{ width = (Random().Next(3000)) |
|
|
|
|
height = (Random().Next(3000)) |
|
|
|
|
colour = (randomBrush ()) :?> Brush |
|
|
|
|
filePath = loadLocation |
|
|
|
|
overlay = None } |
|
|
|
|
let imagesInLoadingTestArea = Directory.GetFileSystemEntries (loadLocation, "*.png") |
|
|
|
|
|
|
|
|
|
let generateSpecs amount = |
|
|
|
|
[for i in 1 .. amount -> (populateSpec ()) ] |
|
|
|
|
let generateLoadPath () = |
|
|
|
|
let rand = Random () |
|
|
|
|
let files = imagesInLoadingTestArea |
|
|
|
|
files.[rand.Next(files.Length)] |
|
|
|
|
|
|
|
|
|
let populateLoadingTestArea () = |
|
|
|
|
printfn "[INFO.] Populating LoadingTestArea..." |
|
|
|
|
generateSpecs 100 |
|
|
|
|
|> List.map makeImage |
|
|
|
|
|> Async.Parallel |
|
|
|
|
|> Async.RunSynchronously |
|
|
|
|
|> ignore |
|
|
|
|
printfn "[INFO.] Finishing populating Saving Test Area." |
|
|
|
|
let generateSavePath originalFilePath = |
|
|
|
|
let fileName = Path.GetFileName originalFilePath |
|
|
|
|
saveLocation + "/" + fileName |
|
|
|
|
|
|
|
|
|
let fileSaved path = File.Exists path |
|
|
|
|
|
|
|
|
|
module PropertyTests = |
|
|
|
|
|
|
|
|
@ -46,22 +40,22 @@
|
|
|
|
|
open System.Drawing |
|
|
|
|
open DeathSocket.GridPainter |
|
|
|
|
open TestingHelpers |
|
|
|
|
open System.IO |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Can apply grid to image and save it`` () = |
|
|
|
|
let oPath = generateLoadPath () |
|
|
|
|
let sPath = generateSavePath oPath |
|
|
|
|
let spec = |
|
|
|
|
{ originalPath = "tba" |
|
|
|
|
savePath = "tba" |
|
|
|
|
{ originalPath = oPath |
|
|
|
|
savePath = sPath |
|
|
|
|
colour = randomBrush () :?> Brush |
|
|
|
|
penWidth = float32 0.002 |
|
|
|
|
penWidth = float32 0.1 |
|
|
|
|
rows = 10 |
|
|
|
|
columns = 10 } |
|
|
|
|
applyGrid spec |> Async.RunSynchronously |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Can populate the LoadingTestArea`` () = |
|
|
|
|
populateLoadingTestArea () |
|
|
|
|
true = true |
|
|
|
|
applyGrid spec |
|
|
|
|
|> Async.RunSynchronously |
|
|
|
|
(File.Exists sPath) = true |
|
|
|
|
|
|
|
|
|
module UnitTests = |
|
|
|
|
|
|
|
|
@ -72,7 +66,6 @@
|
|
|
|
|
// This test is just a check to make sure the property tests have what they need to run. |
|
|
|
|
[<Fact>] |
|
|
|
|
let ``LoadingTestArea contains at least 100 test images`` () = |
|
|
|
|
let files = Directory.GetFileSystemEntries (loadLocation, "*.png") |
|
|
|
|
let length = files.Length |
|
|
|
|
let result = if length < 100 then false else true |
|
|
|
|
Assert.True result |
|
|
|
|
let length = imagesInLoadingTestArea.Length |
|
|
|
|
let imagesAreThere = if length < 100 then false else true |
|
|
|
|
Assert.True imagesAreThere |