#How to test the state of a private record?

1 messages · Page 1 of 1 (latest)

oblique sigil
#

Here's what I came up with
[<Fact>] let ``Ability score bonus: +2 Con`` () = let character = TestUtils.CreateCharacter(Dwarf, con = 10u) |> Result.ok Assert.Equal(Character.con character, Constitution 12u)

Here's the record
type Character = private { Race: Race Height: Height Weight: Weight Con: Constitution }

So, basically, my solution is
let con character = character.Con
a getter just for testing purposes

Is there a better way? Without creating a getter for the sake of a test?

opal needle
#

Domain-wise how do you plan to access a character's constitution?

#

Simple setting of a record isnt usually worth testing. But processes by which CON gets used or modified do matter