| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.Collections.ObjectModel; |
| | | 4 | | using System.Linq; |
| | | 5 | | using WireMock.Matchers; |
| | | 6 | | using WireMock.Matchers.Request; |
| | | 7 | | using WireMock.Util; |
| | | 8 | | using WireMock.Validation; |
| | | 9 | | |
| | | 10 | | namespace WireMock.RequestBuilders |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// The requests. |
| | | 14 | | /// </summary> |
| | | 15 | | public class Request : RequestMessageCompositeMatcher, IRequestBuilder |
| | | 16 | | { |
| | | 17 | | private readonly IList<IRequestMatcher> _requestMatchers; |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Creates this instance. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <returns>The <see cref="IRequestBuilder"/>.</returns> |
| | | 23 | | public static IRequestBuilder Create() |
| | 312 | 24 | | { |
| | 312 | 25 | | return new Request(new List<IRequestMatcher>()); |
| | 312 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Initializes a new instance of the <see cref="Request"/> class. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <param name="requestMatchers">The request matchers.</param> |
| | 312 | 32 | | private Request(IList<IRequestMatcher> requestMatchers) : base(requestMatchers) |
| | 312 | 33 | | { |
| | 312 | 34 | | _requestMatchers = requestMatchers; |
| | 312 | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Gets the request message matchers. |
| | | 39 | | /// </summary> |
| | | 40 | | /// <typeparam name="T">Type of IRequestMatcher</typeparam> |
| | | 41 | | /// <returns>A List{T}</returns> |
| | | 42 | | public IList<T> GetRequestMessageMatchers<T>() where T : IRequestMatcher |
| | 12 | 43 | | { |
| | 18 | 44 | | return new ReadOnlyCollection<T>(_requestMatchers.Where(rm => rm is T).Cast<T>().ToList()); |
| | 12 | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Gets the request message matcher. |
| | | 49 | | /// </summary> |
| | | 50 | | /// <typeparam name="T">Type of IRequestMatcher</typeparam> |
| | | 51 | | /// <returns>A RequestMatcher</returns> |
| | | 52 | | public T GetRequestMessageMatcher<T>() where T : IRequestMatcher |
| | 4 | 53 | | { |
| | 6 | 54 | | return _requestMatchers.Where(rm => rm is T).Cast<T>().FirstOrDefault(); |
| | 4 | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <inheritdoc cref="IClientIPRequestBuilder.WithClientIP(IStringMatcher[])"/> |
| | | 58 | | public IRequestBuilder WithClientIP(params IStringMatcher[] matchers) |
| | 1 | 59 | | { |
| | 1 | 60 | | Check.NotNullOrEmpty(matchers, nameof(matchers)); |
| | | 61 | | |
| | 1 | 62 | | _requestMatchers.Add(new RequestMessageClientIPMatcher(matchers)); |
| | 1 | 63 | | return this; |
| | 1 | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <inheritdoc cref="IClientIPRequestBuilder.WithClientIP(string[])"/> |
| | | 67 | | public IRequestBuilder WithClientIP(params string[] clientIPs) |
| | 2 | 68 | | { |
| | 2 | 69 | | return WithClientIP(MatchBehaviour.AcceptOnMatch, clientIPs); |
| | 2 | 70 | | } |
| | | 71 | | |
| | | 72 | | /// <inheritdoc cref="IClientIPRequestBuilder.WithClientIP(string[])"/> |
| | | 73 | | public IRequestBuilder WithClientIP(MatchBehaviour matchBehaviour, params string[] clientIPs) |
| | 2 | 74 | | { |
| | 2 | 75 | | Check.NotNullOrEmpty(clientIPs, nameof(clientIPs)); |
| | | 76 | | |
| | 2 | 77 | | _requestMatchers.Add(new RequestMessageClientIPMatcher(matchBehaviour, clientIPs)); |
| | 2 | 78 | | return this; |
| | 2 | 79 | | } |
| | | 80 | | |
| | | 81 | | /// <inheritdoc cref="IClientIPRequestBuilder.WithClientIP(Func{string, bool}[])"/> |
| | | 82 | | public IRequestBuilder WithClientIP(params Func<string, bool>[] funcs) |
| | 1 | 83 | | { |
| | 1 | 84 | | Check.NotNullOrEmpty(funcs, nameof(funcs)); |
| | | 85 | | |
| | 1 | 86 | | _requestMatchers.Add(new RequestMessageClientIPMatcher(funcs)); |
| | 1 | 87 | | return this; |
| | 1 | 88 | | } |
| | | 89 | | |
| | | 90 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithPath(IStringMatcher[])"/> |
| | | 91 | | public IRequestBuilder WithPath(params IStringMatcher[] matchers) |
| | 66 | 92 | | { |
| | 66 | 93 | | Check.NotNullOrEmpty(matchers, nameof(matchers)); |
| | | 94 | | |
| | 66 | 95 | | _requestMatchers.Add(new RequestMessagePathMatcher(matchers)); |
| | 66 | 96 | | return this; |
| | 66 | 97 | | } |
| | | 98 | | |
| | | 99 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithPath(string[])"/> |
| | | 100 | | public IRequestBuilder WithPath(params string[] paths) |
| | 196 | 101 | | { |
| | 196 | 102 | | return WithPath(MatchBehaviour.AcceptOnMatch, paths); |
| | 197 | 103 | | } |
| | | 104 | | |
| | | 105 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithPath(MatchBehaviour, string[])"/> |
| | | 106 | | public IRequestBuilder WithPath(MatchBehaviour matchBehaviour, params string[] paths) |
| | 197 | 107 | | { |
| | 197 | 108 | | Check.NotNullOrEmpty(paths, nameof(paths)); |
| | | 109 | | |
| | 196 | 110 | | _requestMatchers.Add(new RequestMessagePathMatcher(matchBehaviour, paths)); |
| | 197 | 111 | | return this; |
| | 197 | 112 | | } |
| | | 113 | | |
| | | 114 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithPath(Func{string, bool}[])"/> |
| | | 115 | | public IRequestBuilder WithPath(params Func<string, bool>[] funcs) |
| | 1 | 116 | | { |
| | 1 | 117 | | Check.NotNullOrEmpty(funcs, nameof(funcs)); |
| | | 118 | | |
| | 1 | 119 | | _requestMatchers.Add(new RequestMessagePathMatcher(funcs)); |
| | 1 | 120 | | return this; |
| | 1 | 121 | | } |
| | | 122 | | |
| | | 123 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithUrl(IStringMatcher[])"/> |
| | | 124 | | public IRequestBuilder WithUrl(params IStringMatcher[] matchers) |
| | 1 | 125 | | { |
| | 1 | 126 | | Check.NotNullOrEmpty(matchers, nameof(matchers)); |
| | | 127 | | |
| | 1 | 128 | | _requestMatchers.Add(new RequestMessageUrlMatcher(matchers)); |
| | 1 | 129 | | return this; |
| | 1 | 130 | | } |
| | | 131 | | |
| | | 132 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithUrl(string[])"/> |
| | | 133 | | public IRequestBuilder WithUrl(params string[] urls) |
| | 1 | 134 | | { |
| | 1 | 135 | | return WithUrl(MatchBehaviour.AcceptOnMatch, urls); |
| | 1 | 136 | | } |
| | | 137 | | |
| | | 138 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithUrl(MatchBehaviour, string[])"/> |
| | | 139 | | public IRequestBuilder WithUrl(MatchBehaviour matchBehaviour, params string[] urls) |
| | 1 | 140 | | { |
| | 1 | 141 | | Check.NotNullOrEmpty(urls, nameof(urls)); |
| | | 142 | | |
| | 1 | 143 | | _requestMatchers.Add(new RequestMessageUrlMatcher(matchBehaviour, urls)); |
| | 1 | 144 | | return this; |
| | 1 | 145 | | } |
| | | 146 | | |
| | | 147 | | /// <inheritdoc cref="IUrlAndPathRequestBuilder.WithUrl(Func{string, bool}[])"/> |
| | | 148 | | public IRequestBuilder WithUrl(params Func<string, bool>[] funcs) |
| | 1 | 149 | | { |
| | 1 | 150 | | Check.NotNullOrEmpty(funcs, nameof(funcs)); |
| | | 151 | | |
| | 1 | 152 | | _requestMatchers.Add(new RequestMessageUrlMatcher(funcs)); |
| | 1 | 153 | | return this; |
| | 1 | 154 | | } |
| | | 155 | | |
| | | 156 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingDelete(MatchBehaviour)"/> |
| | | 157 | | public IRequestBuilder UsingDelete(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 56 | 158 | | { |
| | 56 | 159 | | _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "DELETE")); |
| | 56 | 160 | | return this; |
| | 56 | 161 | | } |
| | | 162 | | |
| | | 163 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingGet(MatchBehaviour)"/> |
| | | 164 | | public IRequestBuilder UsingGet(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 91 | 165 | | { |
| | 91 | 166 | | _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "GET")); |
| | 91 | 167 | | return this; |
| | 91 | 168 | | } |
| | | 169 | | |
| | | 170 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingHead(MatchBehaviour)"/> |
| | | 171 | | public IRequestBuilder UsingHead(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 1 | 172 | | { |
| | 1 | 173 | | _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "HEAD")); |
| | 1 | 174 | | return this; |
| | 1 | 175 | | } |
| | | 176 | | |
| | | 177 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingPost(MatchBehaviour)"/> |
| | | 178 | | public IRequestBuilder UsingPost(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 68 | 179 | | { |
| | 68 | 180 | | _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "POST")); |
| | 68 | 181 | | return this; |
| | 68 | 182 | | } |
| | | 183 | | |
| | | 184 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingPatch(MatchBehaviour)"/> |
| | | 185 | | public IRequestBuilder UsingPatch(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 2 | 186 | | { |
| | 2 | 187 | | _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "PATCH")); |
| | 2 | 188 | | return this; |
| | 2 | 189 | | } |
| | | 190 | | |
| | | 191 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingPut(MatchBehaviour)"/> |
| | | 192 | | public IRequestBuilder UsingPut(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 14 | 193 | | { |
| | 14 | 194 | | _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "PUT")); |
| | 14 | 195 | | return this; |
| | 14 | 196 | | } |
| | | 197 | | |
| | | 198 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingAnyMethod"/> |
| | | 199 | | public IRequestBuilder UsingAnyMethod() |
| | 26 | 200 | | { |
| | 32 | 201 | | var matchers = _requestMatchers.Where(m => m is RequestMessageMethodMatcher).ToList(); |
| | 80 | 202 | | foreach (var matcher in matchers) |
| | 1 | 203 | | { |
| | 1 | 204 | | _requestMatchers.Remove(matcher); |
| | 1 | 205 | | } |
| | | 206 | | |
| | 26 | 207 | | return this; |
| | 26 | 208 | | } |
| | | 209 | | |
| | | 210 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingAnyVerb"/> |
| | | 211 | | public IRequestBuilder UsingAnyVerb() |
| | 0 | 212 | | { |
| | 0 | 213 | | return UsingAnyMethod(); |
| | 0 | 214 | | } |
| | | 215 | | |
| | | 216 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingMethod(string[])"/> |
| | | 217 | | public IRequestBuilder UsingMethod(params string[] methods) |
| | 22 | 218 | | { |
| | 22 | 219 | | return UsingMethod(MatchBehaviour.AcceptOnMatch, methods); |
| | 22 | 220 | | } |
| | | 221 | | |
| | | 222 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingVerb(string[])"/> |
| | | 223 | | public IRequestBuilder UsingVerb(params string[] verbs) |
| | 0 | 224 | | { |
| | 0 | 225 | | return UsingMethod(verbs); |
| | 0 | 226 | | } |
| | | 227 | | |
| | | 228 | | /// <inheritdoc cref="IMethodRequestBuilder.UsingMethod(MatchBehaviour, string[])"/> |
| | | 229 | | public IRequestBuilder UsingMethod(MatchBehaviour matchBehaviour, params string[] methods) |
| | 22 | 230 | | { |
| | 22 | 231 | | Check.NotNullOrEmpty(methods, nameof(methods)); |
| | | 232 | | |
| | 22 | 233 | | _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, methods)); |
| | 22 | 234 | | return this; |
| | 22 | 235 | | } |
| | | 236 | | |
| | | 237 | | /// <inheritdoc cref="IBodyRequestBuilder.WithBody(string, MatchBehaviour)"/> |
| | | 238 | | public IRequestBuilder WithBody(string body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 2 | 239 | | { |
| | 2 | 240 | | _requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body)); |
| | 2 | 241 | | return this; |
| | 2 | 242 | | } |
| | | 243 | | |
| | | 244 | | /// <inheritdoc cref="IBodyRequestBuilder.WithBody(byte[], MatchBehaviour)"/> |
| | | 245 | | public IRequestBuilder WithBody(byte[] body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 1 | 246 | | { |
| | 1 | 247 | | _requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body)); |
| | 1 | 248 | | return this; |
| | 1 | 249 | | } |
| | | 250 | | |
| | | 251 | | /// <inheritdoc cref="IBodyRequestBuilder.WithBody(object, MatchBehaviour)"/> |
| | | 252 | | public IRequestBuilder WithBody(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 1 | 253 | | { |
| | 1 | 254 | | _requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body)); |
| | 1 | 255 | | return this; |
| | 1 | 256 | | } |
| | | 257 | | |
| | | 258 | | /// <inheritdoc cref="IBodyRequestBuilder.WithBody(IMatcher)"/> |
| | | 259 | | public IRequestBuilder WithBody(IMatcher matcher) |
| | 13 | 260 | | { |
| | 13 | 261 | | Check.NotNull(matcher, nameof(matcher)); |
| | | 262 | | |
| | 13 | 263 | | _requestMatchers.Add(new RequestMessageBodyMatcher(matcher)); |
| | 13 | 264 | | return this; |
| | 13 | 265 | | } |
| | | 266 | | |
| | | 267 | | /// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{string, bool})"/> |
| | | 268 | | public IRequestBuilder WithBody(Func<string, bool> func) |
| | 1 | 269 | | { |
| | 1 | 270 | | Check.NotNull(func, nameof(func)); |
| | | 271 | | |
| | 1 | 272 | | _requestMatchers.Add(new RequestMessageBodyMatcher(func)); |
| | 1 | 273 | | return this; |
| | 1 | 274 | | } |
| | | 275 | | |
| | | 276 | | /// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{byte[], bool})"/> |
| | | 277 | | public IRequestBuilder WithBody(Func<byte[], bool> func) |
| | 1 | 278 | | { |
| | 1 | 279 | | Check.NotNull(func, nameof(func)); |
| | | 280 | | |
| | 1 | 281 | | _requestMatchers.Add(new RequestMessageBodyMatcher(func)); |
| | 1 | 282 | | return this; |
| | 1 | 283 | | } |
| | | 284 | | |
| | | 285 | | /// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{object, bool})"/> |
| | | 286 | | public IRequestBuilder WithBody(Func<object, bool> func) |
| | 1 | 287 | | { |
| | 1 | 288 | | Check.NotNull(func, nameof(func)); |
| | | 289 | | |
| | 1 | 290 | | _requestMatchers.Add(new RequestMessageBodyMatcher(func)); |
| | 1 | 291 | | return this; |
| | 1 | 292 | | } |
| | | 293 | | |
| | | 294 | | /// <inheritdoc cref="IParamsRequestBuilder.WithParam(string, MatchBehaviour)"/> |
| | | 295 | | public IRequestBuilder WithParam(string key, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) |
| | 1 | 296 | | { |
| | 1 | 297 | | Check.NotNull(key, nameof(key)); |
| | | 298 | | |
| | 1 | 299 | | _requestMatchers.Add(new RequestMessageParamMatcher(matchBehaviour, key)); |
| | 1 | 300 | | return this; |
| | 1 | 301 | | } |
| | | 302 | | |
| | | 303 | | /// <inheritdoc cref="IParamsRequestBuilder.WithParam(string, string[])"/> |
| | | 304 | | public IRequestBuilder WithParam(string key, params string[] values) |
| | 3 | 305 | | { |
| | 3 | 306 | | return WithParam(key, MatchBehaviour.AcceptOnMatch, values); |
| | 3 | 307 | | } |
| | | 308 | | |
| | | 309 | | /// <inheritdoc cref="IParamsRequestBuilder.WithParam(string, IStringMatcher[])"/> |
| | | 310 | | public IRequestBuilder WithParam(string key, params IStringMatcher[] matchers) |
| | 1 | 311 | | { |
| | 1 | 312 | | return WithParam(key, MatchBehaviour.AcceptOnMatch, matchers); |
| | 1 | 313 | | } |
| | | 314 | | |
| | | 315 | | /// <inheritdoc cref="IParamsRequestBuilder.WithParam(string, MatchBehaviour, string[])"/> |
| | | 316 | | public IRequestBuilder WithParam(string key, MatchBehaviour matchBehaviour, params string[] values) |
| | 3 | 317 | | { |
| | 3 | 318 | | Check.NotNull(key, nameof(key)); |
| | | 319 | | |
| | 3 | 320 | | _requestMatchers.Add(new RequestMessageParamMatcher(matchBehaviour, key, values)); |
| | 3 | 321 | | return this; |
| | 3 | 322 | | } |
| | | 323 | | |
| | | 324 | | /// <inheritdoc cref="IParamsRequestBuilder.WithParam(string, MatchBehaviour, IStringMatcher[])"/> |
| | | 325 | | public IRequestBuilder WithParam(string key, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers) |
| | 2 | 326 | | { |
| | 2 | 327 | | Check.NotNull(key, nameof(key)); |
| | | 328 | | |
| | 2 | 329 | | _requestMatchers.Add(new RequestMessageParamMatcher(matchBehaviour, key, matchers)); |
| | 2 | 330 | | return this; |
| | 2 | 331 | | } |
| | | 332 | | |
| | | 333 | | /// <inheritdoc cref="IParamsRequestBuilder.WithParam(Func{IDictionary{string, WireMockList{string}}, bool}[])"/ |
| | | 334 | | public IRequestBuilder WithParam(params Func<IDictionary<string, WireMockList<string>>, bool>[] funcs) |
| | 1 | 335 | | { |
| | 1 | 336 | | Check.NotNullOrEmpty(funcs, nameof(funcs)); |
| | | 337 | | |
| | 1 | 338 | | _requestMatchers.Add(new RequestMessageParamMatcher(funcs)); |
| | 1 | 339 | | return this; |
| | 1 | 340 | | } |
| | | 341 | | |
| | | 342 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string, MatchBehaviour)"/> |
| | | 343 | | public IRequestBuilder WithHeader(string name, string pattern, MatchBehaviour matchBehaviour) |
| | 1 | 344 | | { |
| | 1 | 345 | | return WithHeader(name, pattern, true, matchBehaviour); |
| | 1 | 346 | | } |
| | | 347 | | |
| | | 348 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string, bool, MatchBehaviour)"/> |
| | | 349 | | public IRequestBuilder WithHeader(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehav |
| | 39 | 350 | | { |
| | 39 | 351 | | Check.NotNull(name, nameof(name)); |
| | 39 | 352 | | Check.NotNull(pattern, nameof(pattern)); |
| | | 353 | | |
| | 39 | 354 | | _requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, pattern, ignoreCase)); |
| | 39 | 355 | | return this; |
| | 39 | 356 | | } |
| | | 357 | | |
| | | 358 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string[], MatchBehaviour)"/> |
| | | 359 | | public IRequestBuilder WithHeader(string name, string[] patterns, MatchBehaviour matchBehaviour) |
| | 1 | 360 | | { |
| | 1 | 361 | | return WithHeader(name, patterns, true, matchBehaviour); |
| | 1 | 362 | | } |
| | | 363 | | |
| | | 364 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string[], bool, MatchBehaviour)"/> |
| | | 365 | | public IRequestBuilder WithHeader(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBe |
| | 2 | 366 | | { |
| | 2 | 367 | | Check.NotNull(name, nameof(name)); |
| | 2 | 368 | | Check.NotNull(patterns, nameof(patterns)); |
| | | 369 | | |
| | 2 | 370 | | _requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, patterns, ignoreCase)); |
| | 2 | 371 | | return this; |
| | 2 | 372 | | } |
| | | 373 | | |
| | | 374 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, IStringMatcher[])"/> |
| | | 375 | | public IRequestBuilder WithHeader(string name, params IStringMatcher[] matchers) |
| | 1 | 376 | | { |
| | 1 | 377 | | Check.NotNull(name, nameof(name)); |
| | 1 | 378 | | Check.NotNullOrEmpty(matchers, nameof(matchers)); |
| | | 379 | | |
| | 1 | 380 | | _requestMatchers.Add(new RequestMessageHeaderMatcher(name, matchers)); |
| | 1 | 381 | | return this; |
| | 1 | 382 | | } |
| | | 383 | | |
| | | 384 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(Func{IDictionary{string, string[]}, bool}[])"/ |
| | | 385 | | public IRequestBuilder WithHeader(params Func<IDictionary<string, string[]>, bool>[] funcs) |
| | 1 | 386 | | { |
| | 1 | 387 | | Check.NotNullOrEmpty(funcs, nameof(funcs)); |
| | | 388 | | |
| | 1 | 389 | | _requestMatchers.Add(new RequestMessageHeaderMatcher(funcs)); |
| | 1 | 390 | | return this; |
| | 1 | 391 | | } |
| | | 392 | | |
| | | 393 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(string, string, bool, MatchBehaviour)"/> |
| | | 394 | | public IRequestBuilder WithCookie(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehav |
| | 2 | 395 | | { |
| | 2 | 396 | | _requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, pattern, ignoreCase)); |
| | 2 | 397 | | return this; |
| | 2 | 398 | | } |
| | | 399 | | |
| | | 400 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/> |
| | | 401 | | public IRequestBuilder WithCookie(string name, params IStringMatcher[] matchers) |
| | 1 | 402 | | { |
| | 1 | 403 | | Check.NotNullOrEmpty(matchers, nameof(matchers)); |
| | | 404 | | |
| | 1 | 405 | | _requestMatchers.Add(new RequestMessageCookieMatcher(name, matchers)); |
| | 1 | 406 | | return this; |
| | 1 | 407 | | } |
| | | 408 | | |
| | | 409 | | /// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(Func{IDictionary{string, string}, bool}[])"/> |
| | | 410 | | public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs) |
| | 1 | 411 | | { |
| | 1 | 412 | | Check.NotNullOrEmpty(funcs, nameof(funcs)); |
| | | 413 | | |
| | 1 | 414 | | _requestMatchers.Add(new RequestMessageCookieMatcher(funcs)); |
| | 1 | 415 | | return this; |
| | 1 | 416 | | } |
| | | 417 | | } |
| | | 418 | | } |