diff --git a/.gitignore b/.gitignore index edddaec..7d62a42 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ # Project-specific Files /TestCentre/LoadingTestArea/*.png +/TestCentre/SavingTestArea/*.png # User-specific files *.suo @@ -331,3 +332,4 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ + diff --git a/TestCentre/LibraryTests.fs b/TestCentre/LibraryTests.fs index 3cac331..6b7e67c 100644 --- a/TestCentre/LibraryTests.fs +++ b/TestCentre/LibraryTests.fs @@ -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 populateLoadingTestArea () = - printfn "[INFO.] Populating LoadingTestArea..." - generateSpecs 100 - |> List.map makeImage - |> Async.Parallel - |> Async.RunSynchronously - |> ignore - printfn "[INFO.] Finishing populating Saving Test Area." + let generateLoadPath () = + let rand = Random () + let files = imagesInLoadingTestArea + files.[rand.Next(files.Length)] + + 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 [] 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 - - [] - 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. [] 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 \ No newline at end of file + let length = imagesInLoadingTestArea.Length + let imagesAreThere = if length < 100 then false else true + Assert.True imagesAreThere \ No newline at end of file