mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Define multiple scenarios for the same url path and switch to it at run-time? #186
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dnovhorodov on GitHub (Jun 25, 2019).
Hello guys,
In WireMock.NET there is a possibility to define scenarios which acts as a state machine for requests. Very nice 👍
Is there possibility at run-time (hosted by Azure/IIS) route requests to specific pre-loaded scenarios based on some request attribute like header, param, etc.?
Or at least switch mock server to use specific scenario for specific url path (in case of N scenarios for same path) by calling __admin endpoints ?
Currently I found only __admin endpoints to manage collection of scenarios on the server like POST,GET,DELETE. But nothing like ability to switch to use some scenario depending on... request attribute or calling some __admin endpoint.
So my questions:
Could that behavior be achieved by dynamically managing Scenarios collection on the server?
Say on top of wiremock server there some other API running and exposing endpoint like POST api/scenarios/{name}/use which will clear Scenarios collection and load only scenario with {name}
Is it possible to do some side-effect action (Action<> like) on .Given(..) when creating mappings?
@dnovhorodov commented on GitHub (Jul 2, 2019):
Hey mates,
Still didn't get any answers, but I found how to inject custom Owin middleware if you need to have custom behavior. In my case I do it like this:
@StefH commented on GitHub (Jul 2, 2019):
This is indeed also an option to introduce custom logic. I'll add this to the wiki.