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; - } } } }