From 572a521d601861b8171d73c5fb58d45be7f4b7a9 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Tue, 7 Sep 2021 17:58:20 +0200 Subject: [PATCH] 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. --- .../HttpResponseMessageExtensions.cs | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs b/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs index 21226cf4cc..e47e6d7fdb 100644 --- a/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs +++ b/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs @@ -1,11 +1,8 @@ using System.Net; using System.Net.Http; -using System.Threading.Tasks; using FluentAssertions; using FluentAssertions.Primitives; using JetBrains.Annotations; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace TestBuildingBlocks { @@ -32,33 +29,12 @@ public AndConstraint HaveStatusCode(HttpStatusCod { if (Subject.StatusCode != statusCode) { - string responseText = GetFormattedContentAsync(Subject).Result; + string responseText = Subject.Content.ReadAsStringAsync().Result; Subject.StatusCode.Should().Be(statusCode, $"response body returned was:\n{responseText}"); } return new AndConstraint(this); } - - private static async Task GetFormattedContentAsync(HttpResponseMessage responseMessage) - { - string text = await responseMessage.Content.ReadAsStringAsync(); - - try - { - if (text.Length > 0) - { - return JsonConvert.DeserializeObject(text)?.ToString(); - } - } -#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException - catch -#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException - { - // ignored - } - - return text; - } } } }