1
+ // Copyright © WireMock.Net
2
+
3
+ #pragma warning disable CS1591
4
+ using System ;
5
+ using WireMock . Constants ;
6
+
7
+ // ReSharper disable once CheckNamespace
8
+ namespace WireMock . FluentAssertions ;
9
+
10
+ public partial class WireMockAssertions
11
+ {
12
+ [ CustomAssertion ]
13
+ public AndConstraint < WireMockAssertions > UsingConnect ( string because = "" , params object [ ] becauseArgs )
14
+ => UsingMethod ( HttpRequestMethod . CONNECT , because , becauseArgs ) ;
15
+
16
+ [ CustomAssertion ]
17
+ public AndConstraint < WireMockAssertions > UsingDelete ( string because = "" , params object [ ] becauseArgs )
18
+ => UsingMethod ( HttpRequestMethod . DELETE , because , becauseArgs ) ;
19
+
20
+ [ CustomAssertion ]
21
+ public AndConstraint < WireMockAssertions > UsingGet ( string because = "" , params object [ ] becauseArgs )
22
+ => UsingMethod ( HttpRequestMethod . GET , because , becauseArgs ) ;
23
+
24
+ [ CustomAssertion ]
25
+ public AndConstraint < WireMockAssertions > UsingHead ( string because = "" , params object [ ] becauseArgs )
26
+ => UsingMethod ( HttpRequestMethod . HEAD , because , becauseArgs ) ;
27
+
28
+ [ CustomAssertion ]
29
+ public AndConstraint < WireMockAssertions > UsingOptions ( string because = "" , params object [ ] becauseArgs )
30
+ => UsingMethod ( HttpRequestMethod . OPTIONS , because , becauseArgs ) ;
31
+
32
+ [ CustomAssertion ]
33
+ public AndConstraint < WireMockAssertions > UsingPost ( string because = "" , params object [ ] becauseArgs )
34
+ => UsingMethod ( HttpRequestMethod . POST , because , becauseArgs ) ;
35
+
36
+ [ CustomAssertion ]
37
+ public AndConstraint < WireMockAssertions > Using ( string because = "" , params object [ ] becauseArgs )
38
+ => UsingMethod ( HttpRequestMethod . , because , becauseArgs ) ;
39
+
40
+ [ CustomAssertion ]
41
+ public AndConstraint < WireMockAssertions > UsingPut ( string because = "" , params object [ ] becauseArgs )
42
+ => UsingMethod ( HttpRequestMethod . PUT , because , becauseArgs ) ;
43
+
44
+ [ CustomAssertion ]
45
+ public AndConstraint < WireMockAssertions > UsingTrace ( string because = "" , params object [ ] becauseArgs )
46
+ => UsingMethod ( HttpRequestMethod . TRACE , because , becauseArgs ) ;
47
+
48
+ [ CustomAssertion ]
49
+ public AndConstraint < WireMockAssertions > UsingAnyMethod ( string because = "" , params object [ ] becauseArgs )
50
+ => UsingMethod ( Any , because , becauseArgs ) ;
51
+
52
+ [ CustomAssertion ]
53
+ public AndConstraint < WireMockAssertions > UsingMethod ( string method , string because = "" , params object [ ] becauseArgs )
54
+ {
55
+ var any = method == Any ;
56
+ Func < IRequestMessage , bool > predicate = request => ( any && ! string . IsNullOrEmpty ( request . Method ) ) ||
57
+ string . Equals ( request . Method , method , StringComparison . OrdinalIgnoreCase ) ;
58
+
59
+ var ( filter , condition ) = BuildFilterAndCondition ( predicate ) ;
60
+
61
+ _chain
62
+ . BecauseOf ( because , becauseArgs )
63
+ . Given ( ( ) => RequestMessages )
64
+ . ForCondition ( requests => CallsCount == 0 || requests . Any ( ) )
65
+ . FailWith (
66
+ "Expected {context:wiremockserver} to have been called using method {0}{reason}, but no calls were made." ,
67
+ method
68
+ )
69
+ . Then
70
+ . ForCondition ( condition )
71
+ . FailWith (
72
+ "Expected {context:wiremockserver} to have been called using method {0}{reason}, but didn't find it among the methods {1}." ,
73
+ _ => method ,
74
+ requests => requests . Select ( request => request . Method )
75
+ ) ;
76
+
77
+ FilterRequestMessages ( filter ) ;
78
+
79
+ return new AndConstraint < WireMockAssertions > ( this ) ;
80
+ }
81
+ }
0 commit comments