Browse Source

add unit tests for invalid input (createSkiaDataAsync)

master
Craig Oates 5 years ago
parent
commit
61bef0a01e
  1. 2
      DeathSocket/ColourServices.fs
  2. 8
      DeathSocket/GridPainter.fs
  3. 4
      DeathSocket/ImageServices.fs
  4. 91
      TestCentre/LibraryTests.fs

2
DeathSocket/ColourServices.fs

@ -2,8 +2,6 @@
open System.Drawing
open DeathSocket.Domain
open System
open SkiaSharp
let makeBrushFromRGBASpec (spec: RGBASpec) =
let a = int spec.alpha

8
DeathSocket/GridPainter.fs

@ -107,8 +107,8 @@ namespace DeathSocket
printfn "%s" ex.Message
reraise ()
// System.Drawing Functions
// ====================================================================
(* System.Drawing Functions
==================================================================== *)
/// <summary>
/// Determines the (Pen) points needed to draw the appropriate number
@ -171,8 +171,8 @@ namespace DeathSocket
let makeSolidBrushFromRGBASpec (spec: RGBASpec) =
makeBrushFromRGBASpec spec
// SkiaSharp Functions
// ====================================================================
(* SkiaSharp Functions
==================================================================== *)
// NOT TESTED

4
DeathSocket/ImageServices.fs

@ -8,7 +8,7 @@
open SkiaSharp
open System
(* Why the Use of Repeated Code
(* Note on the Use of Repeated Code
===========================================================================
In this file, you will find code which seems duplicated. The areas in
question are mostly the graphics/drawing parts of the file. Before you
@ -17,7 +17,7 @@
also, means it is difficult to pass/return them from one function to the
next. Therefore, the decision made was to accept the duplicated code in
exchange for a smaller memory footprint. Several (large) undisposed images
lurking in an end users RAM can grid their computer to a halt. On top of
lurking in an end users RAM can grind their computer to a halt. On top of
that, they have no means to make alterations to the code. *)
let setLineThickness pDimension aDimension lineWidth =

91
TestCentre/LibraryTests.fs

@ -221,11 +221,96 @@
module UnitTests =
open TestingHelpers
open Xunit
open DeathSocket
open System
open System.IO
open System.Drawing
open Xunit
open DeathSocket
open SkiaSharp
open TestingHelpers
[<Fact>]
let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaBuffer`` () =
let result =
SkiaBuffer ({ filePath = "invalid-file-path"
penWidth = float32 1
skColour = SKColors.Empty
rows = 1
columns = 1 })
|> GridPainter.createSKDataAsync
|> Async.RunSynchronously
Assert.Equal(SKData.Empty, result)
[<Fact>]
let ``An empty SKData object is returned when createSKDataAsync cannot find file when using SkiaRGBBuffer`` () =
let result =
SkiaRGBBuffer ({ filePath = "invalid-file-path"
penWidth = float32 1
red = float32 1
green = float32 1
blue = float32 1
rows = 1
columns = 1 })
|> GridPainter.createSKDataAsync
|> Async.RunSynchronously
Assert.Equal(SKData.Empty, result)
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with SkiaRGB`` () =
let result =
SkiaRGB ({ originalPath = "not needed"
savePath= "not needed"
red = float32 1
green = float32 1
blue = float32 1
penWidth = float32 1
rows = 1
columns = 1})
|> GridPainter.createSKDataAsync
|> Async.RunSynchronously
Assert.Equal(SKData.Empty, result)
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with Skia`` () =
let result =
Skia ({ originalPath = "not needed"
savePath= "not needed"
skColour = SKColors.Empty
penWidth = float32 1
rows = 1
columns = 1 })
|> GridPainter.createSKDataAsync
|> Async.RunSynchronously
Assert.Equal(SKData.Empty, result)
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with Brush`` () =
let result =
Brush ({ originalPath = "not needed"
savePath= "not needed"
colour = Brushes.AliceBlue
penWidth = float32 1
rows = 1
columns = 1 })
|> GridPainter.createSKDataAsync
|> Async.RunSynchronously
Assert.Equal(SKData.Empty, result)
[<Fact>]
let ``An empty SKData object is returned when calling createSKDataAsync with RGBA`` () =
let result =
RGBA ({ originalPath = "not needed"
savePath= "not needed"
red = float 1
green = float 1
blue = float 1
alpha = float 1
penWidth = float32 1
rows = 1
columns = 1 })
|> GridPainter.createSKDataAsync
|> Async.RunSynchronously
Assert.Equal(SKData.Empty, result)
[<Fact>]
let ``Can determine image width using SkiaSharp`` () =

Loading…
Cancel
Save