-
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationstate: releasedThe issue is releasedThe issue is released
Description
Description
The HttpClient section is missing documentation for several matchers and HTTP methods.
Missing Documentation
It.IsBinaryContent()matcher.ForHttps(),.ForHttp()URI scheme filters.WithBodyMatching()content body matching (appears in example but not explained)- PUT, DELETE, PATCH methods (only GET and POST shown)
- CancellationToken support
Suggested Documentation
Expand the "Mocking HttpClient" section with subsections for:
- All HTTP Methods (PUT, DELETE, PATCH)
- Binary Content Matching
- URI Scheme Filtering
- Content Body Matching (explain the feature shown in example)
- CancellationToken Support
All HTTP Methods
Mockolate supports all standard HTTP methods:
// PUT
httpClient.SetupMock.Method.PutAsync(
It.IsAny<string>(), It.IsAny<HttpContent>())
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));
// DELETE
httpClient.SetupMock.Method.DeleteAsync(It.IsAny<string>())
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent));
// PATCH
httpClient.SetupMock.Method.PatchAsync(
It.IsAny<string>(), It.IsAny<HttpContent>())
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));Binary Content Matching
httpClient.SetupMock.Method.PostAsync(
It.IsAny<string>(),
It.IsBinaryContent("application/octet-stream"))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));URI Scheme Filtering
// Match only HTTPS requests
httpClient.VerifyMock.Invoked.GetAsync(
It.IsUri("*api.example.com*").ForHttps())
.Once();
// Match only HTTP requests
httpClient.VerifyMock.Invoked.GetAsync(
It.IsUri("*localhost*").ForHttp())
.Never();Content Body Matching
httpClient.VerifyMock.Invoked.PostAsync(
It.IsAny<string>(),
It.IsStringContent("application/json")
.WithBodyMatching("*\"type\": \"Dark\"*"))
.Once();CancellationToken Support
All HTTP methods support CancellationToken parameters:
var cts = new CancellationTokenSource();
httpClient.SetupMock.Method.GetAsync(
It.IsAny<string>(), It.IsAny<CancellationToken>())
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));
await httpClient.GetAsync("https://example.com", cts.Token);Reactions are currently unavailable
Metadata
Metadata
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationstate: releasedThe issue is releasedThe issue is released