Browse Source

add extra test image and update Test Centre.

master
Craig Oates 5 years ago
parent
commit
78511b232a
  1. 101
      TestCentre/LibraryTests.fs
  2. BIN
      TestCentre/LoadingTestArea/RequiredInfo/ImageTest1.png
  3. BIN
      TestCentre/LoadingTestArea/RequiredInfo/ImageTest2.png
  4. BIN
      TestCentre/LoadingTestArea/RequiredInfo/ImageTest3.png

101
TestCentre/LibraryTests.fs

@ -34,10 +34,17 @@
let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea"
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea"
let fixedSkiaImagePath =
let validSkiaImagePath =
(loadLocation + "/RequiredInfo/Skia-599x336.png")
let fixedSystemDrawingImagePath =
let validSystemDrawingImagePath =
(loadLocation + "/RequiredInfo/SystemDrawing-338x307.png")
let validImagePath =
(loadLocation + "/RequiredInfo/ImageTest1.png")
let validImagePath2 =
(loadLocation + "/RequiredInfo/ImageTest2.png")
let validImagePath3 =
(loadLocation + "/RequiredInfo/ImageTest3.png")
let invalidImagePath = "invalid.png"
let allColours =
let properties =
@ -227,7 +234,7 @@
[<Property>]
let ``Can create a populated SKData buffer when calling createSKDataAsync with SkiaBuffer`` () =
let result () =
SkiaBuffer ({ filePath = fixedSkiaImagePath
SkiaBuffer ({ filePath = validImagePath
skColour = randomSKColour ()
penWidth = float32 (newPenWidth())
rows = newNum ()
@ -239,7 +246,7 @@
[<Property>]
let ``Can create a populated SKData buffer when calling createSKDataAsync with SkiaRGBBuffer`` () =
let result () =
SkiaRGBBuffer ({ filePath = fixedSkiaImagePath
SkiaRGBBuffer ({ filePath = validImagePath3
red = float32 (newNum())
green = float32 (newNum())
blue = float32 (newNum())
@ -263,7 +270,7 @@
[<Fact>]
let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaBuffer`` () =
let result =
SkiaBuffer ({ filePath = "invalid-file-path"
SkiaBuffer ({ filePath = invalidImagePath
penWidth = float32 1
skColour = SKColors.Empty
rows = 1
@ -275,7 +282,7 @@
[<Fact>]
let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaRGBBuffer`` () =
let result =
SkiaRGBBuffer ({ filePath = "invalid-file-path"
SkiaRGBBuffer ({ filePath = invalidImagePath
penWidth = float32 1
red = float32 1
green = float32 1
@ -289,8 +296,8 @@
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with SkiaRGB`` () =
let result =
SkiaRGB ({ originalPath = "not needed"
savePath= "not needed"
SkiaRGB ({ originalPath = validImagePath2
savePath= validImagePath
red = float32 1
green = float32 1
blue = float32 1
@ -304,8 +311,8 @@
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with Skia`` () =
let result =
Skia ({ originalPath = "not needed"
savePath= "not needed"
Skia ({ originalPath = validImagePath3
savePath= validImagePath
skColour = SKColors.Empty
penWidth = float32 1
rows = 1
@ -317,8 +324,8 @@
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with Brush`` () =
let result =
Brush ({ originalPath = "not needed"
savePath= "not needed"
Brush ({ originalPath = validImagePath
savePath= validImagePath
colour = Brushes.AliceBlue
penWidth = float32 1
rows = 1
@ -330,8 +337,8 @@
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with RGBA`` () =
let result =
RGBA ({ originalPath = "not needed"
savePath= "not needed"
RGBA ({ originalPath = validImagePath
savePath= validImagePath
red = float 1
green = float 1
blue = float 1
@ -343,10 +350,28 @@
|> Async.RunSynchronously
Assert.Equal(SKData.Empty, result)
[<Fact>]
let ``Argument Exception is thrown when actualDimensions are set to 0 when calling scaleLineThickness`` () =
let result () =
GridPainter.scaleLineThickness (1, 0) (0, 0) 1.0
Assert.Throws<ArgumentException>(fun () -> result () |> ignore)
[<Fact>]
let ``Argument Exception is thrown when lineThickness is set to 0 when calling scaleLineThickness`` () =
let result () =
GridPainter.scaleLineThickness (1, 0)(1, 0) 0.0
Assert.Throws<ArgumentException>(fun () -> result () |> ignore)
[<Fact>]
let ``Argument Exception is thrown when previewDimensions are set to 0 when calling scaleLineThickness`` () =
let result () =
GridPainter.scaleLineThickness (0, 0) (1, 0) 1.0
Assert.Throws<ArgumentException>(fun () -> result () |> ignore)
[<Fact>]
let ``Can determine image width using SkiaSharp`` () =
let dimensions =
SkiaSharp (fixedSkiaImagePath)
SkiaSharp (validSkiaImagePath)
|> GridPainter.determineImageDimensions
let result () = (fst dimensions) = 599
Assert.True (result ())
@ -354,7 +379,7 @@
[<Fact>]
let ``Can determine image height using SkiaSharp`` () =
let dimensions =
SkiaSharp (fixedSkiaImagePath)
SkiaSharp (validSkiaImagePath)
|> GridPainter.determineImageDimensions
let result () = (snd dimensions) = 336
Assert.True (result ())
@ -362,7 +387,7 @@
[<Fact>]
let ``Can determine image width using SystemDrawing`` () =
let dimensions =
SystemDrawing (fixedSystemDrawingImagePath)
SystemDrawing (validSystemDrawingImagePath)
|> GridPainter.determineImageDimensions
let result () = (fst dimensions) = 338
Assert.True (result ())
@ -370,11 +395,21 @@
[<Fact>]
let ``Can determine image height using SystemDrawing`` () =
let dimensions =
SystemDrawing (fixedSystemDrawingImagePath)
SystemDrawing (validSystemDrawingImagePath)
|> GridPainter.determineImageDimensions
let result () = (snd dimensions) = 307
Assert.True (result ())
[<Fact>]
let ``Divide By Zero Exception is thrown when 0 rows is used when determining horizontal lines`` () =
let result () = GridPainter.determineHorizontalLines 100 100 0
Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
[<Fact>]
let ``Divide By Zero Exception is thrown when 0 columns is used when determining vertical lines`` () =
let result () = GridPainter.determineVerticalLines 100 100 0
Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
(* This test is a pre-test test (a test for the tests if you will...).
It is here to make sure the property test has what it needs to run.
If the property tests fails, here is a good place to start.
@ -394,32 +429,4 @@
for extra context. *)
[<Fact>]
let ``SavingTestArea folder can be found`` () =
Assert.True (Directory.Exists saveLocation)
[<Fact>]
let ``Divide By Zero Exception is thrown when 0 rows is used when determining horizontal lines`` () =
let result () = GridPainter.determineHorizontalLines 100 100 0
Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
[<Fact>]
let ``Divide By Zero Exception is thrown when 0 columns is used when determining vertical lines`` () =
let result () = GridPainter.determineVerticalLines 100 100 0
Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
[<Fact>]
let ``Divide By Zero Exception is thrown when previewDimension is set to 0 when calling scaleLineThickness`` () =
let result () =
GridPainter.scaleLineThickness 0.0 1.0 1.0
Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
[<Fact>]
let ``Divide By Zero Exception is thrown when actualDimension is set to 0 when calling scaleLineThickness`` () =
let result () =
GridPainter.scaleLineThickness 1.0 0.0 1.0
Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
[<Fact>]
let ``Divide By Zero Exception is thrown when lineThickness is set to 0 when calling scaleLineThickness`` () =
let result () =
GridPainter.scaleLineThickness 1.0 1.0 0.0
Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
Assert.True (Directory.Exists saveLocation)

BIN
TestCentre/LoadingTestArea/RequiredInfo/ImageTest1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
TestCentre/LoadingTestArea/RequiredInfo/ImageTest2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
TestCentre/LoadingTestArea/RequiredInfo/ImageTest3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Loading…
Cancel
Save