added empty error
.NET Test / .NET tests (push) Successful in 2m5s

This commit is contained in:
2026-07-12 20:30:35 +04:00
parent 848374972c
commit 4a7cdd6bf1
4 changed files with 247 additions and 15 deletions
@@ -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]