-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Stay in Current State for specified number of requests #494
Comments
Probably the interface can look like: var server = WireMockServer.Start();
server
.Given(Request.Create().WithPath(path).UsingGet())
.InScenario("S")
.WillSetStateTo("bar")
.WhenMatchingCountEquals(2)
.RespondWith(Response.Create().WithBody("Scenario S, Setting State bar"));
server
.Given(Request.Create().WithPath(path).UsingGet())
.InScenario("S")
.WhenStateIs("bar")
.RespondWith(Response.Create().WithBody("Scenario S, State bar")); or var server = WireMockServer.Start();
server
.Given(Request.Create().WithPath(path).UsingGet())
.InScenario("S")
.WillSetStateTo("bar", 2) // 2 = matching count
.RespondWith(Response.Create().WithBody("Scenario S, Setting State bar"));
server
.Given(Request.Create().WithPath(path).UsingGet())
.InScenario("S")
.WhenStateIs("bar")
.RespondWith(Response.Create().WithBody("Scenario S, State bar"));
|
@StefH I would suggest second approach. Here's why:
server
.Given(Request.Create().WithPath(path).UsingGet())
.WhenMatchingCountEquals(2)
.InScenario("S")
.WillSetStateTo("bar")
.RespondWith(Response.Create().WithBody("Scenario S, Setting State bar")); which is not very readable. It can even be used like this: server
.Given(Request.Create().WithPath(path).UsingGet())
.WhenMatchingCountEquals(2)
.RespondWith(Response.Create().WithBody("Scenario S, Setting State bar")); which doesn't make sense. |
@shoaibshakeel381 |
I tested this preview version on my tests and it worked flawlessly. Great job. |
I'll create an official version within some time. |
Hey guy,s I need to write mocks such that a request keeps faulting for a given number of time before it can succeed. I know that I can use Scenarios for this.
But there's a problem. Let's suppose I want to fault my request 2 times before succeeding on 3rd attempt. So I have to write three mocks where flow would be like this:
We can see that first 2 states are just doing same thing. So my question is this: Is it possible to build a mock which stay in its current state for a given number of time, before switching to next one. So my mocks would be like below:
The text was updated successfully, but these errors were encountered: