namespace LibraryTests module PropertyTests = open FsCheck.Xunit open System open System.Drawing open SmoulderingBeachBall.Domain.DomainTypes open System.Reflection open SmoulderingBeachBall.Services open System.IO let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea/" (* '3000' is an arbitary value. It is used to keep the testing times sane. This function is used to randomly generate image sizes but you do not need to use it. The project can handle larger numbers than '3000' but processing takes longer. If you decide to change it, please keep an eye on the saving time. When a image is too big, the project cannot write it to disc fast enough -- sometimes it is because of IO constraints. This means the tests checking for this fail/error will think the image does not exist. To resolved this, add a Thread.Sleep call to the affected tests. Just be aware, the length of sleep-time depends on the size of the image. Also, problems tends to arise around the 15,000 mark. *) let randomInt () = Random().Next(3000) let allColours = let properties = typeof.GetProperties(BindingFlags.Public ||| BindingFlags.Static) let colours = seq { for prop in properties -> prop} |> Seq.toArray colours let randomColour () = let item = allColours.[Random().Next(allColours.Length)] item.GetValue(null, null) let fileSaved width height = let path = saveLocation + width + "x" + height + ".png" File.Exists path [] let ``can create an image with no overlay`` () = // See note accompanying 'randomInt' function for constraints information. let spec = { width = randomInt () height = randomInt () colour = randomColour () :?> Brush filePath = saveLocation overlay = None } makeImage spec |> Async.RunSynchronously fileSaved (spec.width.ToString()) (spec.height.ToString()) = true