From bc6532c6138658619066d30046668d736b90dbdd Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sun, 30 Dec 2018 17:35:18 +0000 Subject: [PATCH] add tests and images for GridPainter (dimensions) function --- DeathSocket/GridPainter.fs | 4 ++-- TestCentre/LibraryTests.fs | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/DeathSocket/GridPainter.fs b/DeathSocket/GridPainter.fs index 4b986b1..985a6e6 100644 --- a/DeathSocket/GridPainter.fs +++ b/DeathSocket/GridPainter.fs @@ -91,9 +91,9 @@ namespace DeathSocket /// information is the thing this function cares about most of all. How /// it is read and what library it uses it secondary. /// - let determineImageDimensions (iType: ImageType) = + let determineImageDimensions (imgType: ImageType) = try - match iType with + match imgType with | SkiaSharp s -> validateFilePath s |> ignore determineSkiaDimensions s diff --git a/TestCentre/LibraryTests.fs b/TestCentre/LibraryTests.fs index d6cc027..bb00d34 100644 --- a/TestCentre/LibraryTests.fs +++ b/TestCentre/LibraryTests.fs @@ -227,9 +227,41 @@ open System open System.IO + [] + let ``Can determine image width using SkiaSharp`` () = + let dimensions = + SkiaSharp (loadLocation + "/RequiredInfo/Skia-599x336.png") + |> GridPainter.determineImageDimensions + let result () = (fst dimensions) = 599 + Assert.True (result ()) + + [] + let ``Can determine image height using SkiaSharp`` () = + let dimensions = + SkiaSharp (loadLocation + "/RequiredInfo/Skia-599x336.png") + |> GridPainter.determineImageDimensions + let result () = (snd dimensions) = 336 + Assert.True (result ()) + + [] + let ``Can determine image width using SystemDrawing`` () = + let dimensions = + SystemDrawing (loadLocation + "/RequiredInfo/SystemDrawing-338x307.png") + |> GridPainter.determineImageDimensions + let result () = (fst dimensions) = 338 + Assert.True (result ()) + + [] + let ``Can determine image height using SystemDrawing`` () = + let dimensions = + SystemDrawing (loadLocation + "/RequiredInfo/SystemDrawing-338x307.png") + |> GridPainter.determineImageDimensions + let result () = (snd dimensions) = 307 + Assert.True (result ()) + (* 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 test fails, here is a good place to start. + If the property tests fails, here is a good place to start. See script.fs (in Test Centre) for information on populating the LoadingTestArea folder. *) []