Scenario : stay on current state for a number of times (#495)

* state

* xml comment
This commit is contained in:
Stef Heyenrath
2020-08-01 18:40:35 +02:00
committed by GitHub
parent 6c27820659
commit 4d0373d4ca
12 changed files with 162 additions and 22 deletions

View File

@@ -23,12 +23,12 @@ namespace WireMock.Owin
{
try
{
string scenario = mapping.Scenario != null && _options.Scenarios.ContainsKey(mapping.Scenario) ? _options.Scenarios[mapping.Scenario].NextState : null;
string nextState = GetNextState(mapping);
mappings.Add(new MappingMatcherResult
{
Mapping = mapping,
RequestMatchResult = mapping.GetRequestMatchResult(request, scenario)
RequestMatchResult = mapping.GetRequestMatchResult(request, nextState)
});
}
catch (Exception ex)
@@ -56,5 +56,18 @@ namespace WireMock.Owin
return (match, partialMatch);
}
private string GetNextState(IMapping mapping)
{
// If the mapping does not have a scenario or _options.Scenarios does not contain this scenario from the mapping,
// just return null to indicate that there is no next state.
if (mapping.Scenario == null || !_options.Scenarios.ContainsKey(mapping.Scenario))
{
return null;
}
// Else just return the next state
return _options.Scenarios[mapping.Scenario].NextState;
}
}
}