Skip to content

Commit 107a3e7

Browse files
author
Bart Koelman
committed
Fixed: crash in test serializer on assertion failure
1 parent 1aed7bb commit 107a3e7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

test/TestBuildingBlocks/HttpResponseMessageExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public AndConstraint<HttpResponseMessageAssertions> HaveStatusCode(HttpStatusCod
3030
if (Subject.StatusCode != statusCode)
3131
{
3232
string responseText = Subject.Content.ReadAsStringAsync().Result;
33-
Subject.StatusCode.Should().Be(statusCode, $"response body returned was:\n{responseText}");
33+
Subject.StatusCode.Should().Be(statusCode, string.IsNullOrEmpty(responseText) ? null : $"response body returned was:\n{responseText}");
3434
}
3535

3636
return new AndConstraint<HttpResponseMessageAssertions>(this);

test/TestBuildingBlocks/IntegrationTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ private TResponseDocument DeserializeResponse<TResponseDocument>(string response
9595
return (TResponseDocument)(object)responseText;
9696
}
9797

98+
if (string.IsNullOrEmpty(responseText))
99+
{
100+
return default;
101+
}
102+
98103
try
99104
{
100105
return JsonSerializer.Deserialize<TResponseDocument>(responseText, SerializerOptions);

0 commit comments

Comments
 (0)