Add Scenario set State method (#1322)

* Add SetScenarioState

* add tests

* summary

* .

* 1.8.13-preview-01

* fix

* fix name
This commit is contained in:
Stef Heyenrath
2025-06-23 08:03:11 +02:00
committed by GitHub
parent 43cff52b69
commit f80925c1fb
11 changed files with 512 additions and 274 deletions

View File

@@ -567,6 +567,32 @@ public partial class WireMockServer : IWireMockServer
return _options.Scenarios.ContainsKey(name) && _options.Scenarios.TryRemove(name, out _);
}
/// <inheritdoc />
[PublicAPI]
public bool SetScenarioState(string name, string? state)
{
if (state == null)
{
return ResetScenario(name);
}
_options.Scenarios.AddOrUpdate(
name,
_ => new ScenarioState
{
Name = name,
NextState = state
},
(_, current) =>
{
current.NextState = state;
return current;
}
);
return true;
}
/// <inheritdoc cref="IWireMockServer.WithMapping(MappingModel[])" />
[PublicAPI]
public IWireMockServer WithMapping(params MappingModel[] mappings)