@@ -152,19 +152,31 @@ public class Serialization_RoundTrip
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Empty_ManyErrors_round_trip()
|
||||
public void EmptyError_serializes_to_null()
|
||||
{
|
||||
// Given
|
||||
Error original = Error.Many(Array.Empty<Error>());
|
||||
var error = Error.Empty;
|
||||
|
||||
// When
|
||||
var json = JsonSerializer.Serialize(original);
|
||||
var deserialized = JsonSerializer.Deserialize<Error>(json);
|
||||
var json = JsonSerializer.Serialize(error);
|
||||
|
||||
// Then
|
||||
deserialized.ShouldBeOfType<ManyErrors>();
|
||||
deserialized!.IsEmpty.ShouldBeTrue();
|
||||
deserialized.Count.ShouldBe(0);
|
||||
json.ShouldBe("null");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyError_filtered_from_ManyErrors_serialization()
|
||||
{
|
||||
// Given
|
||||
var real = Error.New("real_error");
|
||||
var errors = Error.Many(Error.Empty, real);
|
||||
|
||||
// When
|
||||
var json = JsonSerializer.Serialize(errors);
|
||||
|
||||
// Then
|
||||
json.ShouldNotContain("empty");
|
||||
json.ShouldContain("real_error");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user