diff --git a/tests/FSharp.SystemTextJson.Tests/Test.Record.fs b/tests/FSharp.SystemTextJson.Tests/Test.Record.fs index f5370c8..7429051 100644 --- a/tests/FSharp.SystemTextJson.Tests/Test.Record.fs +++ b/tests/FSharp.SystemTextJson.Tests/Test.Record.fs @@ -17,12 +17,10 @@ module NonStruct = [] let ``deserialize empty record with ignore-null-values on`` () = let options = - JsonSerializerOptions(DefaultIgnoreCondition = Serialization.JsonIgnoreCondition.WhenWritingNull) - try - JsonSerializer.Deserialize("{}", options) |> ignore - with - | :? System.NullReferenceException -> failwith "Unexpected NRE." - | ex when ex.Message.Contains("Missing field for record type") -> () // It's expected to fail since the record requires its fields to be initialized. + JsonSerializerOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull) + let ex = + Assert.Throws(fun () -> JsonSerializer.Deserialize("{}", options) |> ignore) + Assert.Contains("Missing field for record type", ex.Message) [] let ``serialize via explicit converter`` () =