Browse Source

update script in Test Centre to create more varied test images.

The images are saved in LoadingTestArea and use async.
master
Craig Oates 6 years ago
parent
commit
34b6aa35e0
  1. 35
      TestCentre/Script.fsx

35
TestCentre/Script.fsx

@ -8,6 +8,7 @@ open System.Reflection
open SmoulderingBeachBall.Domain open SmoulderingBeachBall.Domain
open SmoulderingBeachBall.Services open SmoulderingBeachBall.Services
open System.Threading open System.Threading
open System.Threading
(* Populating LoadingTestArea Folder Scripts (* Populating LoadingTestArea Folder Scripts
=============================================================================== ===============================================================================
@ -18,6 +19,8 @@ and saving them in SavingTestArea. *)
let saveLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea" let saveLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea"
let random = Random()
let allColours = let allColours =
let properties = let properties =
typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static) typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static)
@ -25,20 +28,27 @@ let allColours =
|> Seq.toArray |> Seq.toArray
let randomBrush () = let randomBrush () =
let item = allColours.[Random().Next(allColours.Length)] let item = allColours.[random.Next(allColours.Length)]
item.GetValue(null, null) item.GetValue(null, null)
let populateSpec () = let generateDimensionSizes total =
{ width = (Random().Next(3000)) List.init total (fun _ -> random.Next(3000))
height = (Random().Next(3000))
let randomSize (sizes: int list) =
// (Sleep) Helps to reduce chance of picking the same item twice in quick succession.
Thread.Sleep 100
sizes.Item (random.Next(sizes.Length))
let populateSpec sizes =
{ width = randomSize (sizes)
height = randomSize (sizes)
colour = (randomBrush ()) :?> Brush colour = (randomBrush ()) :?> Brush
filePath = saveLocation filePath = saveLocation
overlay = None } overlay = None }
let generateSpecs amount = let generateSpecs amount =
[for i in 1 .. amount do let imageSizes = generateDimensionSizes amount
Thread.Sleep 500 [for i in 0 .. amount -> (populateSpec (imageSizes)) ]
yield (populateSpec ()) ]
let generateImage spec = let generateImage spec =
printfn "[INFO.] Creating image [Width: %i] [Height: %i] ..." (spec.width) (spec.height) printfn "[INFO.] Creating image [Width: %i] [Height: %i] ..." (spec.width) (spec.height)
@ -46,10 +56,13 @@ let generateImage spec =
let populateLoadingTestArea () = let populateLoadingTestArea () =
printfn "[INFO.] Populating LoadingTestArea..." printfn "[INFO.] Populating LoadingTestArea..."
for spec in generateSpecs 100 do generateSpecs 100
generateImage spec |> List.map generateImage
|> Async.RunSynchronously |> Async.Parallel
|> Async.RunSynchronously
|> ignore
printfn "[INFO.] Finishing populating /LoadingTestArea." printfn "[INFO.] Finishing populating /LoadingTestArea."
// You should only need this once you have passed the above into F# Interactive. // You should only need this once.
// Make sure you have passed the above into F# Interactive.
populateLoadingTestArea () populateLoadingTestArea ()
Loading…
Cancel
Save