mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-24 17:28:27 +02:00
Scenario : stay on current state for a number of times (#495)
* state * xml comment
This commit is contained in:
@@ -79,7 +79,7 @@ namespace WireMock.Owin
|
||||
{
|
||||
foreach (var mapping in _options.Mappings.Values.Where(m => m?.Scenario != null))
|
||||
{
|
||||
// Set start
|
||||
// Set scenario start
|
||||
if (!_options.Scenarios.ContainsKey(mapping.Scenario) && mapping.IsStartState)
|
||||
{
|
||||
_options.Scenarios.TryAdd(mapping.Scenario, new ScenarioState
|
||||
@@ -122,9 +122,7 @@ namespace WireMock.Owin
|
||||
|
||||
if (targetMapping.Scenario != null)
|
||||
{
|
||||
_options.Scenarios[targetMapping.Scenario].NextState = targetMapping.NextState;
|
||||
_options.Scenarios[targetMapping.Scenario].Started = true;
|
||||
_options.Scenarios[targetMapping.Scenario].Finished = targetMapping.NextState == null;
|
||||
UpdateScenarioState(targetMapping);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -157,6 +155,25 @@ namespace WireMock.Owin
|
||||
await CompletedTask;
|
||||
}
|
||||
|
||||
private void UpdateScenarioState(IMapping mapping)
|
||||
{
|
||||
var scenario = _options.Scenarios[mapping.Scenario];
|
||||
|
||||
// Increase the number of times this state has been executed
|
||||
scenario.Counter++;
|
||||
|
||||
// Only if the number of times this state is executed equals the required StateTimes, proceed to next state and reset the counter to 0
|
||||
if (scenario.Counter == (mapping.StateTimes ?? 1))
|
||||
{
|
||||
scenario.NextState = mapping.NextState;
|
||||
scenario.Counter = 0;
|
||||
}
|
||||
|
||||
// Else just update Started and Finished
|
||||
scenario.Started = true;
|
||||
scenario.Finished = mapping.NextState == null;
|
||||
}
|
||||
|
||||
private void LogRequest(LogEntry entry, bool addRequest)
|
||||
{
|
||||
_options.Logger.DebugRequestResponse(LogEntryMapper.Map(entry), entry.RequestMessage.Path.StartsWith("/__admin/"));
|
||||
|
||||
Reference in New Issue
Block a user