@@ -34,7 +34,7 @@ public HttpRequesterMiddlewareTests()
34
34
public void should_call_services_correctly ( )
35
35
{
36
36
this . Given ( x => x . GivenTheRequestIs ( ) )
37
- . And ( x => x . GivenTheRequesterReturns ( new OkResponse < HttpResponseMessage > ( new HttpResponseMessage ( System . Net . HttpStatusCode . OK ) ) ) )
37
+ . And ( x => x . GivenTheRequesterReturns ( new OkResponse < HttpResponseMessage > ( new HttpResponseMessage ( HttpStatusCode . OK ) ) ) )
38
38
. When ( x => x . WhenICallTheMiddleware ( ) )
39
39
. Then ( x => x . ThenTheDownstreamResponseIsSet ( ) )
40
40
. Then ( x => InformationIsLogged ( ) )
@@ -56,12 +56,38 @@ public void should_log_downstream_internal_server_error()
56
56
{
57
57
this . Given ( x => x . GivenTheRequestIs ( ) )
58
58
. And ( x => x . GivenTheRequesterReturns (
59
- new OkResponse < HttpResponseMessage > ( new HttpResponseMessage ( System . Net . HttpStatusCode . InternalServerError ) ) ) )
59
+ new OkResponse < HttpResponseMessage > ( new HttpResponseMessage ( HttpStatusCode . InternalServerError ) ) ) )
60
60
. When ( x => x . WhenICallTheMiddleware ( ) )
61
61
. Then ( x => x . WarningIsLogged ( ) )
62
62
. BDDfy ( ) ;
63
63
}
64
+
65
+ [ Theory ]
66
+ [ Trait ( "Bug" , "1953" ) ]
67
+ [ InlineData ( HttpStatusCode . OK ) ]
68
+ [ InlineData ( HttpStatusCode . PermanentRedirect ) ]
69
+ public void Should_LogInformation_when_status_is_less_than_BadRequest ( HttpStatusCode status )
70
+ {
71
+ this . Given ( x => x . GivenTheRequestIs ( ) )
72
+ . And ( x => x . GivenTheRequesterReturns ( new OkResponse < HttpResponseMessage > ( new HttpResponseMessage ( status ) ) ) )
73
+ . When ( x => x . WhenICallTheMiddleware ( ) )
74
+ . Then ( x => x . InformationIsLogged ( ) )
75
+ . BDDfy ( ) ;
76
+ }
64
77
78
+ [ Theory ]
79
+ [ Trait ( "Bug" , "1953" ) ]
80
+ [ InlineData ( HttpStatusCode . BadRequest ) ]
81
+ [ InlineData ( HttpStatusCode . NotFound ) ]
82
+ public void Should_LogWarning_when_status_is_BadRequest_or_greater ( HttpStatusCode status )
83
+ {
84
+ this . Given ( x => x . GivenTheRequestIs ( ) )
85
+ . And ( x => x . GivenTheRequesterReturns ( new OkResponse < HttpResponseMessage > ( new HttpResponseMessage ( status ) ) ) )
86
+ . When ( x => x . WhenICallTheMiddleware ( ) )
87
+ . Then ( x => x . WarningIsLogged ( ) )
88
+ . BDDfy ( ) ;
89
+ }
90
+
65
91
private void ThenTheErrorIsSet ( )
66
92
{
67
93
_httpContext . Items . Errors ( ) . Count . ShouldBeGreaterThan ( 0 ) ;
@@ -103,18 +129,14 @@ private void ThenTheDownstreamResponseIsSet()
103
129
private void WarningIsLogged ( )
104
130
{
105
131
_logger . Verify (
106
- x => x . LogWarning (
107
- It . IsAny < Func < string > > ( )
108
- ) ,
132
+ x => x . LogWarning ( It . IsAny < Func < string > > ( ) ) ,
109
133
Times . Once ) ;
110
134
}
111
135
112
136
private void InformationIsLogged ( )
113
137
{
114
138
_logger . Verify (
115
- x => x . LogInformation (
116
- It . IsAny < Func < string > > ( )
117
- ) ,
139
+ x => x . LogInformation ( It . IsAny < Func < string > > ( ) ) ,
118
140
Times . Once ) ;
119
141
}
120
142
}
0 commit comments