Created
February 19, 2018 15:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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