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 1
1
using System . Net ;
2
2
using System . Net . Http ;
3
- using System . Threading . Tasks ;
4
3
using FluentAssertions ;
5
4
using FluentAssertions . Primitives ;
6
5
using JetBrains . Annotations ;
7
- using Newtonsoft . Json ;
8
- using Newtonsoft . Json . Linq ;
9
6
10
7
namespace TestBuildingBlocks
11
8
{
@@ -32,33 +29,12 @@ public AndConstraint<HttpResponseMessageAssertions> HaveStatusCode(HttpStatusCod
32
29
{
33
30
if ( Subject . StatusCode != statusCode )
34
31
{
35
- string responseText = GetFormattedContentAsync ( Subject ) . Result ;
32
+ string responseText = Subject . Content . ReadAsStringAsync ( ) . Result ;
36
33
Subject . StatusCode . Should ( ) . Be ( statusCode , $ "response body returned was:\n { responseText } ") ;
37
34
}
38
35
39
36
return new AndConstraint < HttpResponseMessageAssertions > ( this ) ;
40
37
}
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
- }
62
38
}
63
39
}
64
40
}
You can’t perform that action at this time.
0 commit comments