Skip to content

Instantly share code, notes, and snippets.

@jsquire
Created February 19, 2018 15:15
Show Gist options
  • Save jsquire/b2a0684aab1d5458de4832519c5578a7 to your computer and use it in GitHub Desktop.
Save jsquire/b2a0684aab1d5458de4832519c5578a7 to your computer and use it in GitHub Desktop.
A sample illustrating the syntax for using a data member source for an xUnit theory with F# and FsUnit
namespace MachineLearningBook.SpamDetector.UnitTests
module DataSetTests =
open System
open FSharp.Reflection
open MachineLearningBook.SpamDetector
open Xunit
open FsUnit.Xunit
type ``Parsing a DocType should produce the expected results`` () =
/// The set of theory data containing Document.DocType names.
static member DocTypeNameData
with get() = FSharpType.GetUnionCases typeof<DataSet.DocType> |> Seq.map (fun case -> [| case.Name |])
[<Theory>]
[<MemberData("DocTypeNameData")>]
member verify.``Exact DocTypes can be parsed`` (docTypeName:string) =
let result = DataSet.parseDocType docTypeName
result.IsSome |> should be True
result.Value.ToString() |> should equal docTypeName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment