Browse Source

create a public function for creating a solid brush using an RGBASpec.

Add property tests for the above function.
master
Craig Oates 6 years ago
parent
commit
1719640dc9
  1. 2
      DeathSocket/ColourServices.fs
  2. 3
      DeathSocket/GridPainter.fs
  3. 24
      TestCentre/LibraryTests.fs

2
DeathSocket/ColourServices.fs

@ -3,7 +3,6 @@
open System.Drawing
open DeathSocket.Domain
// not tested
let makeBrushFromRGBASpec (spec: RGBASpec) =
let a = int spec.alpha
let r = int spec.red
@ -12,7 +11,6 @@
let colour = Color.FromArgb (a, r, g, b)
new SolidBrush (colour)
// not tested
let makeBrushFromRGBA r g b a =
let colour = Color.FromArgb (a, r, g, b)
new SolidBrush (colour)

3
DeathSocket/GridPainter.fs

@ -55,9 +55,10 @@ namespace DeathSocket
// let applyCMYKGridAsync -- to be added at a later date.
// not tested.
let makeSolidBrushFromRGBA r g b a = makeBrushFromRGBA r g b a
let makeSolidBrushFromRGBASpec spec = makeBrushFromRGBASpec spec
// not tested or completed.
let makeSolidBrushFromCMYK c m y k =
""

24
TestCentre/LibraryTests.fs

@ -20,6 +20,7 @@
open System.Drawing
open System.Reflection
open System.IO
open DeathSocket.Domain
let rand = Random ()
@ -68,6 +69,18 @@
files
|> Array.iter (fun f -> File.Delete(f))
let makeTestRGBASpec r g b a =
{ originalPath = "test path"
savePath = "test path"
alpha = float a
red = float r
green = float g
blue = float b
penWidth = float32 10
rows = newNum ()
columns = newNum () }
module PropertyTests =
open FsCheck.Xunit
@ -108,6 +121,17 @@
let brush = makeSolidBrushFromRGBA r g b a
brush.Color = referenceColour
[<Property>]
let ``SolidBrush colour matches the RGBASpec`` () =
let a = newRGBANum ()
let r = newRGBANum ()
let g = newRGBANum ()
let b = newRGBANum ()
let referenceColour = Color.FromArgb (a, r, g, b)
let referenceSpec = makeTestRGBASpec r g b a
let brush = makeSolidBrushFromRGBASpec referenceSpec
brush.Color = referenceColour
[<Property>]
let ``Can return a collection of points which represent a grids horizontal lines`` () =

Loading…
Cancel
Save