Closed eetawil closed 4 months ago
So you are looking for this code?
.WithStatusCode(Func<IRequestMessage, int> statusCodeFactory)
which can be used like:
.WithStatusCode(req => GenerateStatus(req))
Yes this could work , but I was wondering if there's a way to do it in a single shot?
.WithBody(req => GenerateBody(req))
.WithStatusCode(??) <== Use here the result from GenerateBody
Here when generating the body dynamically can it also set the status code without the need of reprocessing the request again?
Or maybe the Obj
returned by GenerateBody => Func<IRequestMessage, Obj>
could be retrieved and reused in .WithStatusCode
???
In that case. You need "WithCallback".
Thank you I didn't know about that, I'll look into that. Again, thank you for answering our questions and being available!
Hi, I have this mock setup like this and now I want to also make the status code dynamic (200 or 400) based on the request that I will parse in the "GenerateBody" method, how can I achieve that here?