File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ public Rule WhenGet()
4949 return this ;
5050 }
5151
52+ /// <summary>
53+ /// Add a rule that the HttpRequest.Method is POST
54+ /// </summary>
55+ public Rule WhenPost ( )
56+ {
57+ Predictions . Add ( ( request ) =>
58+ {
59+ return request . Method == "POST" ;
60+ } ) ;
61+ return this ;
62+ }
63+
5264 /// <summary>
5365 /// Add a rule that the request url matches a regex expression
5466 /// </summary>
Original file line number Diff line number Diff line change @@ -83,6 +83,23 @@ public async Task WhenPredictGet_GetAsync_ShouldSucceed()
8383 AssertOkResponse ( actual ) ;
8484 }
8585
86+ [ Test ]
87+ public async Task WhenPredictPost_PostAsync_ShouldSucceed ( )
88+ {
89+ // Arrange
90+ _server . CurrentRuleSet
91+ . AddRule ( )
92+ . WhenPost ( )
93+ . SetOkResponse ( _okResponse ) ;
94+ var client = _server . CreateClient ( ) ;
95+
96+ // Act
97+ var actual = await client . PostAsync ( "/" , new StringContent ( "dummy" ) ) ;
98+
99+ // Assert
100+ AssertOkResponse ( actual ) ;
101+ }
102+
86103 [ Test ]
87104 public async Task WhenPredictGet_PostAsync_ShouldFail ( )
88105 {
You can’t perform that action at this time.
0 commit comments