From 78511b232ad5b352bbd4dabf4698e6fe1b822777 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 31 Dec 2018 16:18:08 +0000 Subject: [PATCH] add extra test image and update Test Centre. --- TestCentre/LibraryTests.fs | 101 ++++++++++-------- .../RequiredInfo/ImageTest1.png | Bin 0 -> 1098 bytes .../RequiredInfo/ImageTest2.png | Bin 0 -> 1098 bytes .../RequiredInfo/ImageTest3.png | Bin 0 -> 1098 bytes 4 files changed, 54 insertions(+), 47 deletions(-) create mode 100644 TestCentre/LoadingTestArea/RequiredInfo/ImageTest1.png create mode 100644 TestCentre/LoadingTestArea/RequiredInfo/ImageTest2.png create mode 100644 TestCentre/LoadingTestArea/RequiredInfo/ImageTest3.png diff --git a/TestCentre/LibraryTests.fs b/TestCentre/LibraryTests.fs index 3b124dd..f158f0f 100644 --- a/TestCentre/LibraryTests.fs +++ b/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 @@ [] 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 @@ [] 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 @@ [] 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 @@ [] 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 @@ [] 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 @@ [] 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 @@ [] 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 @@ [] 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) + [] + 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(fun () -> result () |> ignore) + + [] + 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(fun () -> result () |> ignore) + + [] + 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(fun () -> result () |> ignore) + [] 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 @@ [] 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 @@ [] 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 @@ [] let ``Can determine image height using SystemDrawing`` () = let dimensions = - SystemDrawing (fixedSystemDrawingImagePath) + SystemDrawing (validSystemDrawingImagePath) |> GridPainter.determineImageDimensions let result () = (snd dimensions) = 307 Assert.True (result ()) + [] + 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(fun () -> result () |> ignore) + + [] + 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(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. *) [] let ``SavingTestArea folder can be found`` () = - Assert.True (Directory.Exists saveLocation) - - [] - 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(fun () -> result () |> ignore) - - [] - 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(fun () -> result () |> ignore) - - [] - 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(fun () -> result () |> ignore) - - [] - 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(fun () -> result () |> ignore) - - [] - 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(fun () -> result () |> ignore) \ No newline at end of file + Assert.True (Directory.Exists saveLocation) \ No newline at end of file diff --git a/TestCentre/LoadingTestArea/RequiredInfo/ImageTest1.png b/TestCentre/LoadingTestArea/RequiredInfo/ImageTest1.png new file mode 100644 index 0000000000000000000000000000000000000000..dc71c54a0aa15ec69766078608667384a76452e9 GIT binary patch literal 1098 zcmeAS@N?(olHy`uVBq!ia0y~yU<6@f4mO}ja&5N&kYX$ja(7}_cTVOdki(Mh=