If you don't mind using reflections, the isUnionCase function from this answer may be convenient:
increment state |> isUnionCase <@ StateTwo @> |> should equal true
Note that this is a bit verbose, because you need to call a function call before comparing the values.
A similar but easier approach would be to compare tags:
Beware that this is not type safe, and you can easily mistype the name of a union case.
What I would do is create similar DUs for the purpose of comparison:
type MyStateCase = | StateOneCase | StateTwoCase let categorize = function | StateOne _ -> StateOneCase | StateTwo _ -> StateTwoCase
This way you define categorize once and use it several times.
increment state |> categorize |> should equal StateTwoCase
pad source share