Browse Source

add test which checks the applyRGBAGrid function.

master
Craig Oates 6 years ago
parent
commit
b6662fc0ea
  1. 8
      DeathSocket/GridPainter.fs
  2. 1
      DeathSocket/ImageServices.fs
  3. 29
      TestCentre/LibraryTests.fs

8
DeathSocket/GridPainter.fs

@ -41,7 +41,6 @@ namespace DeathSocket
printfn "File could not be found at %s" ex.Message
}
// Not tested.
let applyRGBAGridAsync (spec: RGBASpec) =
async {
try
@ -53,15 +52,14 @@ namespace DeathSocket
printfn "File could not be found at %s" ex.Message
}
// let applyCMYKGridAsync -- to be added at a later date.
let makeSolidBrushFromRGBA r g b a = makeBrushFromRGBA r g b a
let makeSolidBrushFromRGBASpec spec = makeBrushFromRGBASpec spec
// let applyCMYKGridAsync -- to be added at a later date.
// not tested or completed.
let makeSolidBrushFromCMYK c m y k =
""
//let makeSolidBrushFromCMYK c m y k = ""
/// <summary>
/// Determines the (Pen) points needed to draw the appropriate number of horizontal lines (I.E. rows).

1
DeathSocket/ImageServices.fs

@ -51,7 +51,6 @@
for line in verticalLines do graphics.DrawLines (pen, line)
clone.Save (spec.savePath)
// Not tested
let drawRGBAGrid (spec: RGBASpec) =
// The temp. file is used as a way to convert images with indexed pixels.
use original = Bitmap.FromFile spec.originalPath

29
TestCentre/LibraryTests.fs

@ -46,6 +46,8 @@
Intended for horizontal and vertical line tests. *)
let newNum () = rand.Next(1, 1000)
let newPenWidth () = rand.Next (1, 10)
let newRGBANum () = rand.Next (255)
let imagesInLoadingTestArea =
@ -92,7 +94,7 @@
open System
[<Property>]
let ``Can apply grid to image and save it`` () =
let ``Can apply grid to image and save it using BrushSpec`` () =
(* You should end up with one image left over in SavingTestArea.
Comment out the "reset" function to see all the images produced,
by this test. This will mean you will need to manually delete the
@ -104,13 +106,36 @@
{ originalPath = oPath
savePath = sPath
colour = randomBrush () :?> Brush
penWidth = float32 1
penWidth = float32 (newPenWidth())
rows = 10
columns = 10 }
applyBrushSpecGridAsync spec
|> Async.RunSynchronously
(File.Exists sPath) = true
[<Property>]
let ``Can apply grid to image and save it using RGBASpec`` () =
(* You should end up with one image left over in SavingTestArea.
Comment out the "reset" function to see all the images produced,
by this test. This will mean you will need to manually delete the
images yourself if you do. *)
resetSavingTestArea ()
let oPath = generateLoadPath ()
let sPath = generateSavePath oPath
let (spec: RGBASpec) =
{ originalPath = oPath
savePath = sPath
alpha = float (newRGBANum ())
red = float (newRGBANum ())
green = float (newRGBANum ())
blue = float (newRGBANum ())
penWidth = float32 (newPenWidth())
rows = 10
columns = 10 }
applyRGBAGridAsync spec
|> Async.RunSynchronously
(File.Exists sPath) = true
[<Property>]
let ``SolidBrush colour matches the individual RGBA values`` () =
let a = newRGBANum ()

Loading…
Cancel
Save