Files
raft-fable/Raft.Test/TestNetworkAction.fs
patrick f46557926e
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Modernise CI (#5)
Co-authored-by: Smaug123 <3138005+Smaug123@users.noreply.github.com>
Reviewed-on: #5
2025-09-09 08:18:41 +00:00

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"