File tree Expand file tree Collapse file tree 1 file changed +1
-25
lines changed Expand file tree Collapse file tree 1 file changed +1
-25
lines changed Original file line number Diff line number Diff line change 11using System . Net ;
22using System . Net . Http ;
3- using System . Threading . Tasks ;
43using FluentAssertions ;
54using FluentAssertions . Primitives ;
65using JetBrains . Annotations ;
7- using Newtonsoft . Json ;
8- using Newtonsoft . Json . Linq ;
96
107namespace 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}
You can’t perform that action at this time.
0 commit comments