-
Notifications
You must be signed in to change notification settings - Fork 4
Matching a request
skwasjer edited this page Jan 17, 2020
·
11 revisions
MockHttp provides a fluent API to make setting up request expectations and verifications easy.
Method | Description |
---|---|
.Method("POST") |
Matches the request method. |
.RequestUri("http://localhost/exact/match?query=string") |
Matches an url. Accepts wildcard * . |
.QueryString("key", "value") |
Matches a query string by one or more key/value pairs. Note: the overload that accepts a full query string must be URI data escaped. |
.WithoutQueryString() |
Matches a request without query string. |
.Content("text content") |
Matches the request content body. |
.JsonContent(new { name = "John" }) |
Matches the request content body as JSON. Requires 'skwas.MockHttp.Json' package |
.WithoutContent() |
Matches a request without content. |
.PartialContent("text content") |
Matches the content body partially. |
.ContentType("application/json; charset=utf-8") |
Matches the request content type. |
.Header("Authorization", "Bearer 123") |
Matches request headers by one or more key/value pairs. |
.FormData("key", "value") |
Matches form url encoded or multipart encoded form data by one or more key/value pairs. Note: the overload that accepts a string must be URI data escaped. |
.Any(any => any |
Matches when at least one of the inner configured conditions is true. |
.Where(request => true|false) |
Matches the request using a custom predicate/expression. |
.Version("2.0") |
Matches the request by HTTP message version. |