Skip to content

Commit 0487b73

Browse files
author
Bart Koelman
committed
Removed re-indent of response body on HTTP status code mismatch in tests, because we already use indenting in TestableStartup, so this is no longer needed.
1 parent 897d2b6 commit 0487b73

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed
Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
using System.Net;
22
using System.Net.Http;
3-
using System.Threading.Tasks;
43
using FluentAssertions;
54
using FluentAssertions.Primitives;
65
using JetBrains.Annotations;
7-
using Newtonsoft.Json;
8-
using Newtonsoft.Json.Linq;
96

107
namespace TestBuildingBlocks
118
{
@@ -32,33 +29,12 @@ public AndConstraint<HttpResponseMessageAssertions> HaveStatusCode(HttpStatusCod
3229
{
3330
if (Subject.StatusCode != statusCode)
3431
{
35-
string responseText = GetFormattedContentAsync(Subject).Result;
32+
string responseText = Subject.Content.ReadAsStringAsync().Result;
3633
Subject.StatusCode.Should().Be(statusCode, $"response body returned was:\n{responseText}");
3734
}
3835

3936
return new AndConstraint<HttpResponseMessageAssertions>(this);
4037
}
41-
42-
private static async Task<string> GetFormattedContentAsync(HttpResponseMessage responseMessage)
43-
{
44-
string text = await responseMessage.Content.ReadAsStringAsync();
45-
46-
try
47-
{
48-
if (text.Length > 0)
49-
{
50-
return JsonConvert.DeserializeObject<JObject>(text)?.ToString();
51-
}
52-
}
53-
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
54-
catch
55-
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
56-
{
57-
// ignored
58-
}
59-
60-
return text;
61-
}
6238
}
6339
}
6440
}

0 commit comments

Comments
 (0)