We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently, creating a mock HttpClient looks like this:
var mockHandler = new MockHttpMessageHandler(); mockHandler.When("urAl").Respond(responseA); mockHandler.When("urlA").Respond(responseB); var httpClient = new HttpClient(mockHandler);
This could be made cleaner, at least for single-url mocks, via an AsHttpClient() method:
AsHttpClient()
var httpClient = new MockHttpMessageHandler() .When("urlA").Respond(responseA) .AsHttpClient();
This could be taken one step further by having Respond return the MockHttpMessageHandler, allowing the following:
Respond
MockHttpMessageHandler
var httpClient = new MockHttpMessageHandler() .When("urlA").Respond(responseA) .When("urlB").Respond(responseB) .AsHttpClient();
It would even work for complex requirements with some imaginative spacing:
var httpClient = new MockHttpMessageHandler() .When("urlA") .WithQueryString("key", "value") .Respond(responseA) .When("urlB") .Respond(responseB) .AsHttpClient();
It's important that these changes be made in a backward-compatible fashion.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Currently, creating a mock HttpClient looks like this:
This could be made cleaner, at least for single-url mocks, via an
AsHttpClient()
method:This could be taken one step further by having
Respond
return theMockHttpMessageHandler
, allowing the following:It would even work for complex requirements with some imaginative spacing:
It's important that these changes be made in a backward-compatible fashion.
The text was updated successfully, but these errors were encountered: