-
-
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
Stateful support #48
Comments
No plans, until your question ;-) I'll take a look at the idea and check if this can be implemented in WireMock.net |
I have implemented this functionality for in-process solution. but I can't create PR as have no permissions. |
Mostly the idea is simply to add such syntax:
|
What you can do is fork this project, and then build your changes there and then make a PR to this project. Or what you also can do, is zip your changes and provide this code to me. |
Created a PR #49 |
I see, currently reviewing and testing. |
had to add 1 update: in case the next state is not specified - the current will not be changed (will not be set to NULL) |
I will look, however I'm also looking to build in support for multiple states or scenarios. |
what do you mean by multiple states? do you have any examples?
are you talking about something similar to |
Multiple states : Be able to define multiple states which will behave. Scenarios : I think I like the original idea from wiremock.org I'm building the code based on your PR. |
I see. something like
do you plan to keep backward compatibility? |
in case you decided what is the expected semantic and contract I can update PR |
Thanks for the offer, but currently I'm trying to build it according to my idea, I'll let you know if I need help. Multiple states means ; multiple parallel states should be supported, like unit-test as defined below should be fine: [Fact]
public async Task Should_process_request_if_equals_state_and_multiple_state_defined()
{
// given
_server = FluentMockServer.Start();
_server
.Given(Request.Create()
.WithPath("/state1")
.UsingGet())
.InScenario("s1")
.WillSetStateTo("Test state 1")
.RespondWith(Response.Create()
.WithBody("No state msg 1"));
_server
.Given(Request.Create()
.WithPath("/foo")
.UsingGet())
.InScenario("s1")
.WhenStateIs("Test state 1")
.RespondWith(Response.Create()
.WithBody("Test state msg 1"));
_server
.Given(Request.Create()
.WithPath("/state2")
.UsingGet())
.InScenario("s2")
.WillSetStateTo("Test state 2")
.RespondWith(Response.Create()
.WithBody("No state msg 2"));
_server
.Given(Request.Create()
.WithPath("/foo")
.UsingGet())
.InScenario("s2")
.WhenStateIs("Test state 2")
.RespondWith(Response.Create()
.WithBody("Test state msg 2"));
// when
string url = "http://localhost:" + _server.Ports[0];
var responseNoState1 = await new HttpClient().GetStringAsync(url + "/state1");
var responseNoState2 = await new HttpClient().GetStringAsync(url + "/state2");
var responseWithState1 = await new HttpClient().GetStringAsync(url + "/foo");
var responseWithState2 = await new HttpClient().GetStringAsync(url + "/foo");
// then
Check.That(responseNoState1).Equals("No state msg 1");
Check.That(responseWithState1).Equals("Test state msg 1");
Check.That(responseNoState2).Equals("No state msg 2");
Check.That(responseWithState2).Equals("Test state msg 2");
} |
looks good. will use this syntax meanwhile. |
See my code at https://github.com/WireMock-Net/WireMock.Net/tree/stateful-behavior I'll extend this code to also support the JSON for this... |
Code merged to master, still need to add some text to wiki... |
looks great! |
Yes, I think I can release version 1.0.2.4 on NuGet. I keep you informed here when. |
Done |
thanks a lot! |
Is there a plan to support stateful behavior functionality?
The text was updated successfully, but these errors were encountered: