-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
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
Access request within HttpTest RespondWith for dynamic response #673
Comments
Allow HttpTest.RespondWith to access the request when constructing the response.
I'm not sure I agree with your premise, because we're specifically within the context of testing, where your inputs are "known" (usually hard-coded), as are your expected results. If you know the details of the request that will be made (and in a test you should), then you should be able to set up the fake response "statically". Maybe I'm missing something? |
I agree that the request and response should be well known but may include data that is automatically generated, that needs to be included in the response. |
That makes sense. Could be scenarios where this simplifies test setup too. I don't know that I love how |
I have another example where this is relevant. The code that I'm testing is parallel, even though the responses are known, I do not known the order in which they will be called. The following code illustrates the problem. I'm basically making 100 parallel calls and saying that response body should equal to request body
Ideally I would like to receive |
Not all responses can be purely static, some are dynamic based on the request.
For example, a user defines a request identifier in the body/header and expects the response to include this.
There are lots of good methods for filtering the request but none as far as I could see for creating a dynamic response.
Potential changes required
No breaking changes are needed
FakeHttpMessageHandler:
HttpTestSetup:
The text was updated successfully, but these errors were encountered: