mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
[PR #49] [CLOSED] stateful behavior #747
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?
📋 Pull Request Information
Original PR: https://github.com/wiremock/WireMock.Net/pull/49
Author: @dmtrrk
Created: 10/4/2017
Status: ❌ Closed
Base:
master← Head:stateful-behavior📝 Commits (3)
ab017bestateful behavior + tests22248c0do not change state if WillSetStateTo is not defined8da005cthe next state can not be null📊 Changes
8 files changed (+233 additions, -3 deletions)
View changed files
📝
src/WireMock.Net/Mapping.cs(+28 -0)📝
src/WireMock.Net/Owin/WireMockMiddleware.cs(+7 -0)📝
src/WireMock.Net/Properties/AssemblyInfo.cs(+2 -1)📝
src/WireMock.Net/Server/IRespondWithAProvider.cs(+14 -0)📝
src/WireMock.Net/Server/RespondWithAProvider.cs(+20 -1)📝
test/WireMock.Net.Tests/FluentMockServerTests.cs(+1 -1)➕
test/WireMock.Net.Tests/StatefulBehaviorTests.cs(+112 -0)➕
test/WireMock.Net.Tests/WireMockMiddlewareTests.cs(+49 -0)📄 Description
This PR adds stateful behavior similar to wiremock.
By default there are no changes in semantic. All previous code will work without any changes.
There are 2 methods added in
IRespondWithAProviderinterface:IRespondWithAProvider WhenStateIs(object state);- defined mapping will be processed only in case the current state is equals to specified.IRespondWithAProvider WillSetStateTo(object state);- In case the concrete mapping was selected and executed with the success, the current state will be changed to the specified.All states are per server. The default state is
nullso for the entry request it is not required to specifyWhenStateIs.Both methods can be used together or separately.
Dynamic typing is used over generics, so state is of
objecttype.Usage example:
Once this mapping is executed, the state will be changed to
Test state, so it will not be executed the next time.Test state.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.