Browse Source

add loading and saving test area in Test Centre.

Include files in test areas for extra information about them.
Add default spec test in console tests.
master
Craig Oates 6 years ago
parent
commit
041f34ed27
  1. 2
      DeathSocketCLI/Commands.fs
  2. 2
      DeathSocketCLI/Validation.fs
  3. 54
      TestCentre/ConsoleTests.fs
  4. 3
      TestCentre/LoadingTestArea/AboutLoadingTestArea.txt
  5. BIN
      TestCentre/LoadingTestArea/LoadTest.png
  6. 2
      TestCentre/SavingTestArea/AboutSavingTestArea.txt
  7. 10
      TestCentre/TestCentre.fsproj
  8. 1
      TestCentre/packages.config

2
DeathSocketCLI/Commands.fs

@ -3,7 +3,7 @@
module ConsoleCommands =
open System
open DeathSocket.GridPainter
open DeathSocket.Validation
open DeathSocketCLI.Validation
open System.IO
open Console.Waterworks
open Console.Waterworks.Attributes

2
DeathSocketCLI/Validation.fs

@ -1,4 +1,4 @@
module DeathSocket.Validation
module DeathSocketCLI.Validation
open DeathSocket
open System.Drawing

54
TestCentre/ConsoleTests.fs

@ -1,11 +1,13 @@
namespace ConsoleTests
module PropertyTests =
module TestingHelpers =
open System
open FsCheck.Xunit
open DeathSocket.Validation
open System.Drawing
open DeathSocketCLI.Validation
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea"
let loadLocation = __SOURCE_DIRECTORY__ + "/LoadingTestArea"
let testingColourArray =
colourList
@ -14,7 +16,23 @@
|> Seq.toArray
let randomColour () =
testingColourArray.[Random().Next(testingColourArray.Length)]
testingColourArray.[Random().Next(testingColourArray.Length - 1)]
let randomBrush () =
colourList
|> Map.toSeq
|> Seq.map snd
|> Seq.toArray
|> Array.item (Random().Next(colourList.Count))
module PropertyTests =
open System
open FsCheck.Xunit
open DeathSocketCLI.Validation
open System.Drawing
open TestingHelpers
open DeathSocket.Domain
[<Property>]
let ``Pen width is set greater than 0`` () =
@ -24,21 +42,37 @@
let ``Parsed colour matches expected colour`` () =
let expectedColour = (randomColour ())
let brush = parseColour (expectedColour)
let convertedBrush = (brush :?> SolidBrush).Color.Name.ToLower()
let convertedBrush = ((brush :?> SolidBrush).Color.Name.ToLower())
convertedBrush = expectedColour
[<Property>]
let ``Can make an intended default image specification`` () =
let loadPath = loadLocation + "/LoadTest.png"
let savePath = saveLocation + "/SaveTest.png"
let defaultSpec =
{ originalPath = loadPath
savePath = savePath
colour = Brushes.White
penWidth = setPenWidth 1000 1000
rows = 10
columns = 10 }
let spec = buildDefaultSpec loadPath savePath
defaultSpec = spec
module UnitTests =
open System.IO
open DeathSocket.Validation
open DeathSocketCLI.Validation
open Xunit
let saveLocation = __SOURCE_DIRECTORY__ + "/SavingTestArea"
open TestingHelpers
[<Fact>]
let ``Saving Test Area can be located`` () =
Assert.True (Directory.Exists (saveLocation))
Assert.True (Directory.Exists saveLocation)
[<Fact>]
let ``Loading Test Area can be located`` () =
Assert.True (Directory.Exists loadLocation)
[<Fact>]
let ``Colour list is not empty`` () =

3
TestCentre/LoadingTestArea/AboutLoadingTestArea.txt

@ -0,0 +1,3 @@
This folder is the test area for loading images which are used in the Test Centre.
Images in here should not be deleted.
If you create a test which involves loading any pre-determined images (or any other content), please store it in this folder.

BIN
TestCentre/LoadingTestArea/LoadTest.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

2
TestCentre/SavingTestArea/AboutSavingTestArea.txt

@ -0,0 +1,2 @@
This folder is the test area for saving the images produced in Test Centre.
When a test produces an image, it should save it in here and conduct any processing on it here also.

10
TestCentre/TestCentre.fsproj

@ -45,6 +45,13 @@
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" />
<ItemGroup>
<Content Include="SavingTestArea\AboutSavingTestArea.txt" />
<Content Include="LoadingTestArea\AboutLoadingTestArea.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="LoadingTestArea\LoadTest.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="ConsoleTests.fs" />
<None Include="Script.fsx" />
@ -64,6 +71,9 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common">
<HintPath>..\packages\System.Drawing.Common.4.5.0\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.ValueTuple">
<Private>True</Private>

1
TestCentre/packages.config

@ -3,6 +3,7 @@
<package id="FsCheck" version="2.11.0" targetFramework="net471" />
<package id="FsCheck.Xunit" version="2.11.0" targetFramework="net471" />
<package id="FSharp.Core" version="4.5.2" targetFramework="net471" />
<package id="System.Drawing.Common" version="4.5.0" targetFramework="net471" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net471" />
<package id="xunit" version="2.4.0" targetFramework="net471" />
<package id="xunit.abstractions" version="2.0.3" targetFramework="net471" />

Loading…
Cancel
Save