Co-authored-by: Smaug123 <3138005+Smaug123@users.noreply.github.com> Reviewed-on: #5
39 lines
1.1 KiB
Forth
39 lines
1.1 KiB
Forth
namespace Raft.Test
|
|
|
|
open FsCheck.FSharp
|
|
open Raft
|
|
open System.Collections.Generic
|
|
open NUnit.Framework
|
|
open FsCheck
|
|
open FsUnitTyped
|
|
|
|
[<TestFixture>]
|
|
module TestNetworkAction =
|
|
|
|
[<Test>]
|
|
let ``Generator hits all cases`` () =
|
|
let populate (cases : HashSet<_>) (a : NetworkAction<'a>) : bool =
|
|
cases.Add (a.GetType ()) |> ignore
|
|
true
|
|
|
|
let authoritativeCases = HashSet ()
|
|
Check.QuickThrowOnFailure (populate authoritativeCases)
|
|
|
|
let authoritativeCases =
|
|
authoritativeCases |> Seq.map (fun ty -> ty.FullName) |> Set.ofSeq
|
|
|
|
let ourCases = HashSet ()
|
|
|
|
populate ourCases
|
|
|> Prop.forAll (Arb.fromGen (NetworkAction.generate 5))
|
|
|> Check.QuickThrowOnFailure
|
|
|
|
let ourCases = ourCases |> Seq.map (fun ty -> ty.FullName) |> Set.ofSeq
|
|
Set.difference authoritativeCases ourCases |> shouldBeEmpty
|
|
|
|
// Sanity check that we are actually measuring what we think we're measuring
|
|
ourCases
|
|
|> Seq.map (fun name -> name.Split ('[') |> Array.head)
|
|
|> Set.ofSeq
|
|
|> shouldContain "Raft.NetworkAction`1+DropMessage"
|