Browse Source

Moved the helper functions in unit tests into Helper module.

They have produced good results in unit tests and clean enough to be used in the property tests, hence the moving out.
master
Craig Oates 6 years ago
parent
commit
4ce12a41f7
  1. 17
      TestCentre/Helpers.fs
  2. 1
      TestCentre/TestCentre.fsproj
  3. 24
      TestCentre/UnitTests.fs

17
TestCentre/Helpers.fs

@ -0,0 +1,17 @@
module Helpers
open System.Text.RegularExpressions
let countSentences text =
let count =
Regex.Split(text, @"(?<=[\.\!\?]\s)")
|> Array.length
count
let endsAsIntended (text: string) =
match text.Chars (text.Length - 1) with
| '.' -> true
| '!' -> true
| '?' -> true
| _ -> false

1
TestCentre/TestCentre.fsproj

@ -56,6 +56,7 @@
<Import Project="$(FSharpTargetsPath)" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Helpers.fs" />
<Compile Include="TestingConstants.fs" />
<Compile Include="InputGeneration.fs" />
<Compile Include="UnitTests.fs" />

24
TestCentre/UnitTests.fs

@ -6,14 +6,7 @@
open System
open System.IO
open InputGeneration
open System.Text.RegularExpressions
(* End of Session Note - Monday 23rd July
==================================================================================================================
[] Remove the "contains a full stop" tests -- no longer needed due to change in functionality.
[] Update the "end with a full-stop" tests -- expanded the way a sentence can end.
[] Double check PropertyTests.fs
*)
open Helpers
module ``File Access Tests`` =
@ -119,21 +112,6 @@
module ``Contents Tests`` =
// This function is mostly for the "cleaning" functions, hence placement.
// Feel free to use through this module if needed.
let private countSentences text =
let count =
Regex.Split(text, @"(?<=[\.\!\?]\s)")
|> Array.length
count
let private endsAsIntended (text: string) =
match text.Chars (text.Length - 1) with
| '.' -> true
| '!' -> true
| '?' -> true
| _ -> false
[<Fact>]
let ``CleanResult returns intended number of sentences`` () =
let desiredSentencesCount = (DefaultSentenceCount())

Loading…
Cancel
Save