Browse Source
Add scripts to Test Centre to populate LoadingTestArea folder with images for testing. Update .gitignore file to ignore .png files in LoadingTestArea.master
Craig Oates
6 years ago
5 changed files with 126 additions and 2 deletions
@ -0,0 +1,64 @@ |
|||||||
|
namespace LibraryTests |
||||||
|
|
||||||
|
module TestingHelpers = |
||||||
|
|
||||||
|
open System |
||||||
|
open System.Drawing |
||||||
|
open System.Reflection |
||||||
|
open SmoulderingBeachBall.Domain |
||||||
|
open SmoulderingBeachBall.Services |
||||||
|
|
||||||
|
let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea" |
||||||
|
|
||||||
|
let allColours = |
||||||
|
let properties = |
||||||
|
typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static) |
||||||
|
seq { for prop in properties -> prop} |
||||||
|
|> Seq.toArray |
||||||
|
|
||||||
|
let randomBrush () = |
||||||
|
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 generateSpecs amount = |
||||||
|
[for i in 1 .. amount -> (populateSpec ()) ] |
||||||
|
|
||||||
|
let populateLoadingTestArea () = |
||||||
|
printfn "[INFO.] Populating LoadingTestArea..." |
||||||
|
generateSpecs 100 |
||||||
|
|> List.map makeImage |
||||||
|
|> Async.Parallel |
||||||
|
|> Async.RunSynchronously |
||||||
|
|> ignore |
||||||
|
printfn "[INFO.] Finishing populating Saving Test Area." |
||||||
|
|
||||||
|
module PropertyTests = |
||||||
|
|
||||||
|
open FsCheck.Xunit |
||||||
|
open DeathSocket |
||||||
|
open System.Drawing |
||||||
|
open DeathSocket.GridPainter |
||||||
|
open TestingHelpers |
||||||
|
|
||||||
|
[<Property>] |
||||||
|
let ``Can apply grid to image and save it`` () = |
||||||
|
let spec = |
||||||
|
{ originalPath = "tba" |
||||||
|
savePath = "tba" |
||||||
|
colour = randomBrush () :?> Brush |
||||||
|
penWidth = float32 0.002 |
||||||
|
rows = 10 |
||||||
|
columns = 10 } |
||||||
|
applyGrid spec |> Async.RunSynchronously |
||||||
|
|
||||||
|
[<Property>] |
||||||
|
let ``Can populate the LoadingTestArea`` () = |
||||||
|
populateLoadingTestArea () |
||||||
|
true = true |
@ -1,3 +1,55 @@ |
|||||||
// Testing scripts to go here... |
// These DLL's must be built before you can use them in this script. |
||||||
|
#r "bin/Debug/System.Drawing.Common.dll" |
||||||
|
#r "bin/Debug/SmoulderingBeachBall.dll" |
||||||
|
|
||||||
let saveLocation = __SOURCE_DIRECTORY__ + "\\SavingTestArea" |
open System |
||||||
|
open System.Drawing |
||||||
|
open System.Reflection |
||||||
|
open SmoulderingBeachBall.Domain |
||||||
|
open SmoulderingBeachBall.Services |
||||||
|
open System.Threading |
||||||
|
|
||||||
|
(* Populating LoadingTestArea Folder Scripts |
||||||
|
=============================================================================== |
||||||
|
The following scripts are to help you populate a test folder of images. |
||||||
|
You can then use these images in LibraryTests.fs -- Property Tests. |
||||||
|
The tests consists of loading images from LoadingTestArea, transforming them |
||||||
|
and saving them in SavingTestArea. *) |
||||||
|
|
||||||
|
let saveLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea" |
||||||
|
|
||||||
|
let allColours = |
||||||
|
let properties = |
||||||
|
typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static) |
||||||
|
seq { for prop in properties -> prop} |
||||||
|
|> Seq.toArray |
||||||
|
|
||||||
|
let randomBrush () = |
||||||
|
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 = saveLocation |
||||||
|
overlay = None } |
||||||
|
|
||||||
|
let generateSpecs amount = |
||||||
|
[for i in 1 .. amount do |
||||||
|
Thread.Sleep 500 |
||||||
|
yield (populateSpec ()) ] |
||||||
|
|
||||||
|
let generateImage spec = |
||||||
|
printfn "[INFO.] Creating image [Width: %i] [Height: %i] ..." (spec.width) (spec.height) |
||||||
|
makeImage spec |
||||||
|
|
||||||
|
let populateLoadingTestArea () = |
||||||
|
printfn "[INFO.] Populating LoadingTestArea..." |
||||||
|
for spec in generateSpecs 100 do |
||||||
|
generateImage spec |
||||||
|
|> Async.RunSynchronously |
||||||
|
printfn "[INFO.] Finishing populating /LoadingTestArea." |
||||||
|
|
||||||
|
// You should only need this once you have passed the above into F# Interactive. |
||||||
|
populateLoadingTestArea () |
Loading…
Reference in new issue