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.Services
open System.Threading
open System.Threading
(* Populating LoadingTestArea Folder Scripts
===============================================================================
@ -18,6 +19,8 @@ and saving them in SavingTestArea. *)
let saveLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea"
let random = Random()
let allColours =
let properties =
typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static)
@ -25,20 +28,27 @@ let allColours =
|> Seq.toArray
let randomBrush () =
let item = allColours.[Random().Next(allColours.Length)]
let item = allColours.[random.Next(allColours.Length)]
item.GetValue(null, null)
let populateSpec () =
{ width = (Random().Next(3000))
height = (Random().Next(3000))
let generateDimensionSizes total =
List.init total (fun _ -> 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
filePath = saveLocation
overlay = None }
let generateSpecs amount =
[for i in 1 .. amount do
Thread.Sleep 500
yield (populateSpec ()) ]
let imageSizes = generateDimensionSizes amount
[for i in 0 .. amount -> (populateSpec (imageSizes)) ]
let generateImage spec =
printfn "[INFO.] Creating image [Width: %i] [Height: %i] ..." (spec.width) (spec.height)
@ -46,10 +56,13 @@ let generateImage spec =
let populateLoadingTestArea () =
printfn "[INFO.] Populating LoadingTestArea..."
for spec in generateSpecs 100 do
generateImage spec
|> Async.RunSynchronously
generateSpecs 100
|> List.map generateImage
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
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 ()
Loading…
Cancel
Save