Death Socket consists of three projects. They are a .Net Standard 2.0 library, a console program and a Test Centre. The purpose of this repository is to provide a way for people to add grids to images. https://www.craigoates.net/Software/project/13
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.4 KiB

namespace LibraryTests
module TestingHelpers =
open System
open System.Drawing
open System.Reflection
open SmoulderingBeachBall.Domain
open SmoulderingBeachBall.Services
let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea"
let allColours =
let properties =
typeof<Brushes>.GetProperties(BindingFlags.Public ||| BindingFlags.Static)
seq { for prop in properties -> prop}
|> Seq.toArray
let randomBrush () =
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 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."
module PropertyTests =
open FsCheck.Xunit
open DeathSocket
open System.Drawing
open DeathSocket.GridPainter
open TestingHelpers
[<Property>]
let ``Can apply grid to image and save it`` () =
let spec =
{ originalPath = "tba"
savePath = "tba"
colour = randomBrush () :?> Brush
penWidth = float32 0.002
rows = 10
columns = 10 }
applyGrid spec |> Async.RunSynchronously
[<Property>]
let ``Can populate the LoadingTestArea`` () =
populateLoadingTestArea ()
true = true
module UnitTests =
open System.IO
open TestingHelpers
open Xunit
// This test is just a check to make sure the property tests have what they need to run.
[<Fact>]
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