Craig Oates
5 years ago
2 changed files with 117 additions and 113 deletions
@ -1,113 +1,116 @@ |
|||||||
//// These DLL's must be built before you can use them in this script. |
// These DLL's must be built before you can use them in this script. |
||||||
//#r "bin/Debug/System.Drawing.Common.dll" |
#r "bin\Debug\System.Drawing.Common.dll" |
||||||
//#r "bin/Debug/SmoulderingBeachBall.dll" |
#r @"..\packages\SmoulderingBeachBall.1.0.0\lib\netstandard2.0\SmoulderingBeachBall.dll" |
||||||
|
|
||||||
//open System |
open System |
||||||
//open System.Drawing |
open System.Drawing |
||||||
//open System.Reflection |
open System.Reflection |
||||||
//open SmoulderingBeachBall.Domain |
open SmoulderingBeachBall.Domain |
||||||
//open SmoulderingBeachBall.Services |
open SmoulderingBeachBall.Services |
||||||
//open System.Threading |
open System.Threading |
||||||
//open System.IO |
open System.IO |
||||||
|
|
||||||
//let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea" |
let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea" |
||||||
//let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea" |
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea" |
||||||
//let random = Random() |
let random = Random() |
||||||
|
|
||||||
//(* Resetting the Testing Area Folders Scripts |
(* Resetting the Testing Area Folders Scripts |
||||||
//=============================================================================== |
=============================================================================== |
||||||
//The following scripts are for when you need to "manually" clear out the |
The following scripts are for when you need to "manually" clear out the |
||||||
//LoadingTestArea and SavingTestArea folders. If you do not want to open up the |
LoadingTestArea and SavingTestArea folders. If you do not want to open up the |
||||||
//folder in Explorer and delete the files that way, just run the scripts in this |
folder in Explorer and delete the files that way, just run the scripts in this |
||||||
//section. If you reset the LoadingTestArea, you will need to repopulate it using |
section. If you reset the LoadingTestArea, you will need to repopulate it using |
||||||
//the "Populating LoadingTestArea Folder Scripts" below. *) |
the "Populating LoadingTestArea Folder Scripts" below. *) |
||||||
|
|
||||||
//let resetSavingTestArea () = |
let resetSavingTestArea () = |
||||||
// let files = Directory.GetFileSystemEntries(saveLocation, "*.png") |
let files = Directory.GetFileSystemEntries(saveLocation, "*.png") |
||||||
// match files.Length with |
match files.Length with |
||||||
// | 0 -> () |
| 0 -> () |
||||||
// | _ -> |
| _ -> |
||||||
// files |
files |
||||||
// |> Array.iter (fun f -> File.Delete(f)) |
|> Array.iter (fun f -> File.Delete(f)) |
||||||
|
|
||||||
//let resetLoadingTestArea () = |
let resetLoadingTestArea () = |
||||||
// let files = Directory.GetFileSystemEntries(loadLocation, "*.png") |
let files = Directory.GetFileSystemEntries(loadLocation, "*.png") |
||||||
// match files.Length with |
match files.Length with |
||||||
// | 0 -> () |
| 0 -> () |
||||||
// | _ -> |
| _ -> |
||||||
// files |
files |
||||||
// |> Array.iter (fun f -> File.Delete(f)) |
|> Array.iter (fun f -> File.Delete(f)) |
||||||
|
|
||||||
//// Run these when the above functions have been added to F# interactive. |
// Run these when the above functions have been added to F# interactive. |
||||||
//resetSavingTestArea () |
resetSavingTestArea () |
||||||
//resetLoadingTestArea () |
resetLoadingTestArea () |
||||||
|
|
||||||
//(* Populating LoadingTestArea Folder Scripts |
(* Populating LoadingTestArea Folder Scripts |
||||||
//=============================================================================== |
=============================================================================== |
||||||
//The following scripts are to help you populate a test folder with test images. |
The following scripts are to help you populate a test folder with test images. |
||||||
//You can then use these images in LibraryTests.fs -- Property Tests. |
You can then use these images in LibraryTests.fs -- Property Tests. |
||||||
//The tests consists of loading images from LoadingTestArea, transforming them |
The tests consists of loading images from LoadingTestArea, transforming them |
||||||
//and saving them in SavingTestArea. *) |
and saving them in SavingTestArea. *) |
||||||
|
|
||||||
//let allColours = |
let allColours = |
||||||
// let properties = |
let properties = |
||||||
// typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static) |
typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static) |
||||||
// seq { for prop in properties -> prop} |
seq { for prop in properties -> prop} |
||||||
// |> 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 generateDimensionSizes total = |
let generateDimensionSizes total = |
||||||
// List.init total (fun _ -> random.Next(3000)) |
List.init total (fun _ -> random.Next(3000)) |
||||||
|
|
||||||
//let randomSize (sizes: int list) = |
let randomSize (sizes: int list) = |
||||||
// // (Sleep) Helps to reduce chance of picking the same item twice in quick succession. |
// (Sleep) Helps to reduce chance of picking the same item twice in quick succession. |
||||||
// Thread.Sleep 100 |
Thread.Sleep 100 |
||||||
// sizes.Item (random.Next(sizes.Length)) |
sizes.Item (random.Next(sizes.Length)) |
||||||
|
|
||||||
//let populateSpec sizes = |
let populateSpec sizes = |
||||||
// Brush ({ filePath = loadLocation |
let spec: SmoulderingBeachBall.Domain.DomainTypes.ImageSpec = |
||||||
// height = randomSize (sizes) |
{ filePath = loadLocation |
||||||
// colour = (randomBrush ()) :?> Brush |
width = randomSize (sizes) |
||||||
// overlay = None }) |
height = randomSize (sizes) |
||||||
|
colour = (randomBrush ()) :?> Brush |
||||||
//let generateSpecs amount = |
overlay = None } |
||||||
// let imageSizes = generateDimensionSizes amount |
spec |
||||||
// [for i in 0 .. amount -> (populateSpec (imageSizes)) ] |
|
||||||
|
let generateSpecs amount = |
||||||
//let generateImage spec = |
let imageSizes = generateDimensionSizes amount |
||||||
// printfn "[INFO.] Creating image [Width: %i] [Height: %i] ..." (spec.width) (spec.height) |
[for i in 0 .. amount -> (populateSpec (imageSizes)) ] |
||||||
// makeImage spec |
|
||||||
|
let generateImage (spec: ImageSpec) = |
||||||
//let populateLoadingTestArea () = |
printfn "[INFO.] Creating image [Width: %i] [Height: %i] ..." (spec.width) (spec.height) |
||||||
// printfn "[INFO.] Populating LoadingTestArea..." |
makeImage spec |
||||||
// generateSpecs 100 |
|
||||||
// |> List.map generateImage |
let populateLoadingTestArea () = |
||||||
// |> Async.Parallel |
printfn "[INFO.] Populating LoadingTestArea..." |
||||||
// |> Async.RunSynchronously |
generateSpecs 100 |
||||||
// |> ignore |
|> List.map generateImage |
||||||
// printfn "[INFO.] Finishing populating /LoadingTestArea." |
|> Async.Parallel |
||||||
|
|> Async.RunSynchronously |
||||||
//// You should only need this once. |
|> ignore |
||||||
//// Make sure you have passed the above into F# Interactive. |
printfn "[INFO.] Finishing populating /LoadingTestArea." |
||||||
//populateLoadingTestArea () |
|
||||||
|
// You should only need this once. |
||||||
//(* Creating the Saving Test Area Script |
// Make sure you have passed the above into F# Interactive. |
||||||
//============================================================================== |
populateLoadingTestArea () |
||||||
//This bit of code is for creating the SavingTestArea folder which Test Centre |
|
||||||
//will use when it runs its tests. You will normally only need to run this code |
(* Creating the Saving Test Area Script |
||||||
//when you have just cloned this repository or you accidently deleted said |
============================================================================== |
||||||
//folder. In other words, you should only need to use it once. *) |
This bit of code is for creating the SavingTestArea folder which Test Centre |
||||||
|
will use when it runs its tests. You will normally only need to run this code |
||||||
//let createSavingTestArea () = |
when you have just cloned this repository or you accidently deleted said |
||||||
// match Directory.Exists saveLocation with |
folder. In other words, you should only need to use it once. *) |
||||||
// | false -> |
|
||||||
// Directory.CreateDirectory saveLocation |> ignore |
let createSavingTestArea () = |
||||||
// printfn "SavingTestArea created." |
match Directory.Exists saveLocation with |
||||||
// | _ -> printfn "SavingTestArea already exists." |
| false -> |
||||||
|
Directory.CreateDirectory saveLocation |> ignore |
||||||
//(* Before calling this function, make sure the test checking to see if this |
printfn "SavingTestArea created." |
||||||
//folder exists is failing first. *) |
| _ -> printfn "SavingTestArea already exists." |
||||||
//createSavingTestArea () |
|
||||||
|
(* Before calling this function, make sure the test checking to see if this |
||||||
|
folder exists is failing first. *) |
||||||
|
createSavingTestArea () |
Loading…
Reference in new issue