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 loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea"
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea" let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea"
let fixedSkiaImagePath = let validSkiaImagePath =
(loadLocation + "/RequiredInfo/Skia-599x336.png") (loadLocation + "/RequiredInfo/Skia-599x336.png")
let fixedSystemDrawingImagePath = let validSystemDrawingImagePath =
(loadLocation + "/RequiredInfo/SystemDrawing-338x307.png") (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 allColours =
let properties = let properties =
@ -227,7 +234,7 @@
[<Property>] [<Property>]
let ``Can create a populated SKData buffer when calling createSKDataAsync with SkiaBuffer`` () = let ``Can create a populated SKData buffer when calling createSKDataAsync with SkiaBuffer`` () =
let result () = let result () =
SkiaBuffer ({ filePath = fixedSkiaImagePath SkiaBuffer ({ filePath = validImagePath
skColour = randomSKColour () skColour = randomSKColour ()
penWidth = float32 (newPenWidth()) penWidth = float32 (newPenWidth())
rows = newNum () rows = newNum ()
@ -239,7 +246,7 @@
[<Property>] [<Property>]
let ``Can create a populated SKData buffer when calling createSKDataAsync with SkiaRGBBuffer`` () = let ``Can create a populated SKData buffer when calling createSKDataAsync with SkiaRGBBuffer`` () =
let result () = let result () =
SkiaRGBBuffer ({ filePath = fixedSkiaImagePath SkiaRGBBuffer ({ filePath = validImagePath3
red = float32 (newNum()) red = float32 (newNum())
green = float32 (newNum()) green = float32 (newNum())
blue = float32 (newNum()) blue = float32 (newNum())
@ -263,7 +270,7 @@
[<Fact>] [<Fact>]
let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaBuffer`` () = let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaBuffer`` () =
let result = let result =
SkiaBuffer ({ filePath = "invalid-file-path" SkiaBuffer ({ filePath = invalidImagePath
penWidth = float32 1 penWidth = float32 1
skColour = SKColors.Empty skColour = SKColors.Empty
rows = 1 rows = 1
@ -275,7 +282,7 @@
[<Fact>] [<Fact>]
let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaRGBBuffer`` () = let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaRGBBuffer`` () =
let result = let result =
SkiaRGBBuffer ({ filePath = "invalid-file-path" SkiaRGBBuffer ({ filePath = invalidImagePath
penWidth = float32 1 penWidth = float32 1
red = float32 1 red = float32 1
green = float32 1 green = float32 1
@ -289,8 +296,8 @@
[<Fact>] [<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with SkiaRGB`` () = let ``An empty SKData object is returned when calling createSKDataAsync with SkiaRGB`` () =
let result = let result =
SkiaRGB ({ originalPath = "not needed" SkiaRGB ({ originalPath = validImagePath2
savePath= "not needed" savePath= validImagePath
red = float32 1 red = float32 1
green = float32 1 green = float32 1
blue = float32 1 blue = float32 1
@ -304,8 +311,8 @@
[<Fact>] [<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with Skia`` () = let ``An empty SKData object is returned when calling createSKDataAsync with Skia`` () =
let result = let result =
Skia ({ originalPath = "not needed" Skia ({ originalPath = validImagePath3
savePath= "not needed" savePath= validImagePath
skColour = SKColors.Empty skColour = SKColors.Empty
penWidth = float32 1 penWidth = float32 1
rows = 1 rows = 1
@ -317,8 +324,8 @@
[<Fact>] [<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with Brush`` () = let ``An empty SKData object is returned when calling createSKDataAsync with Brush`` () =
let result = let result =
Brush ({ originalPath = "not needed" Brush ({ originalPath = validImagePath
savePath= "not needed" savePath= validImagePath
colour = Brushes.AliceBlue colour = Brushes.AliceBlue
penWidth = float32 1 penWidth = float32 1
rows = 1 rows = 1
@ -330,8 +337,8 @@
[<Fact>] [<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with RGBA`` () = let ``An empty SKData object is returned when calling createSKDataAsync with RGBA`` () =
let result = let result =
RGBA ({ originalPath = "not needed" RGBA ({ originalPath = validImagePath
savePath= "not needed" savePath= validImagePath
red = float 1 red = float 1
green = float 1 green = float 1
blue = float 1 blue = float 1
@ -343,10 +350,28 @@
|> Async.RunSynchronously |> Async.RunSynchronously
Assert.Equal(SKData.Empty, result) 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>] [<Fact>]
let ``Can determine image width using SkiaSharp`` () = let ``Can determine image width using SkiaSharp`` () =
let dimensions = let dimensions =
SkiaSharp (fixedSkiaImagePath) SkiaSharp (validSkiaImagePath)
|> GridPainter.determineImageDimensions |> GridPainter.determineImageDimensions
let result () = (fst dimensions) = 599 let result () = (fst dimensions) = 599
Assert.True (result ()) Assert.True (result ())
@ -354,7 +379,7 @@
[<Fact>] [<Fact>]
let ``Can determine image height using SkiaSharp`` () = let ``Can determine image height using SkiaSharp`` () =
let dimensions = let dimensions =
SkiaSharp (fixedSkiaImagePath) SkiaSharp (validSkiaImagePath)
|> GridPainter.determineImageDimensions |> GridPainter.determineImageDimensions
let result () = (snd dimensions) = 336 let result () = (snd dimensions) = 336
Assert.True (result ()) Assert.True (result ())
@ -362,7 +387,7 @@
[<Fact>] [<Fact>]
let ``Can determine image width using SystemDrawing`` () = let ``Can determine image width using SystemDrawing`` () =
let dimensions = let dimensions =
SystemDrawing (fixedSystemDrawingImagePath) SystemDrawing (validSystemDrawingImagePath)
|> GridPainter.determineImageDimensions |> GridPainter.determineImageDimensions
let result () = (fst dimensions) = 338 let result () = (fst dimensions) = 338
Assert.True (result ()) Assert.True (result ())
@ -370,11 +395,21 @@
[<Fact>] [<Fact>]
let ``Can determine image height using SystemDrawing`` () = let ``Can determine image height using SystemDrawing`` () =
let dimensions = let dimensions =
SystemDrawing (fixedSystemDrawingImagePath) SystemDrawing (validSystemDrawingImagePath)
|> GridPainter.determineImageDimensions |> GridPainter.determineImageDimensions
let result () = (snd dimensions) = 307 let result () = (snd dimensions) = 307
Assert.True (result ()) 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...). (* 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. 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. If the property tests fails, here is a good place to start.
@ -394,32 +429,4 @@
for extra context. *) for extra context. *)
[<Fact>] [<Fact>]
let ``SavingTestArea folder can be found`` () = let ``SavingTestArea folder can be found`` () =
Assert.True (Directory.Exists saveLocation) 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)

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