mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-28 11:51:48 +01:00
stateful behavior + tests
This commit is contained in:
@@ -40,5 +40,19 @@ namespace WireMock.Server
|
||||
/// </summary>
|
||||
/// <param name="provider">The provider.</param>
|
||||
void RespondWith(IResponseProvider provider);
|
||||
|
||||
/// <summary>
|
||||
/// Execute this respond only in case the current state is equal to specified one
|
||||
/// </summary>
|
||||
/// <param name="state">Any object which identifies the current state</param>
|
||||
/// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
|
||||
IRespondWithAProvider WhenStateIs(object state);
|
||||
|
||||
/// <summary>
|
||||
/// Once this mapping is executed the state will be changed to specified one
|
||||
/// </summary>
|
||||
/// <param name="state">Any object which identifies the new state</param>
|
||||
/// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
|
||||
IRespondWithAProvider WillSetStateTo(object state);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@ namespace WireMock.Server
|
||||
private Guid? _guid;
|
||||
private string _title;
|
||||
|
||||
private object _executionConditionState = null;
|
||||
private object _nextState = null;
|
||||
|
||||
/// <summary>
|
||||
/// The _registration callback.
|
||||
/// </summary>
|
||||
@@ -42,7 +45,19 @@ namespace WireMock.Server
|
||||
public void RespondWith(IResponseProvider provider)
|
||||
{
|
||||
var mappingGuid = _guid ?? Guid.NewGuid();
|
||||
_registrationCallback(new Mapping(mappingGuid, _title, _requestMatcher, provider, _priority));
|
||||
_registrationCallback(new Mapping(mappingGuid, _title, _requestMatcher, provider, _priority, _executionConditionState, _nextState));
|
||||
}
|
||||
|
||||
public IRespondWithAProvider WhenStateIs(object state)
|
||||
{
|
||||
_executionConditionState = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IRespondWithAProvider WillSetStateTo(object state)
|
||||
{
|
||||
_nextState = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user