mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-18 07:13:46 +01:00
scenario and state (mapping json model)
This commit is contained in:
@@ -31,6 +31,22 @@ namespace WireMock.Admin.Mappings
|
||||
/// </value>
|
||||
public int? Priority { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Scenario.
|
||||
/// </summary>
|
||||
public string Scenario { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Execution state condition for the current mapping.
|
||||
/// </summary>
|
||||
public object WhenStateIs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The next state which will be signaled after the current mapping execution.
|
||||
/// In case the value is null state will not be changed.
|
||||
/// </summary>
|
||||
public object SetStateTo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the request.
|
||||
/// </summary>
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace WireMock.Matchers.Request
|
||||
/// <summary>
|
||||
/// The scenario and state matcher.
|
||||
/// </summary>
|
||||
public class RequestMessageScenarioAndStateMatcher : IRequestMatcher
|
||||
internal class RequestMessageScenarioAndStateMatcher : IRequestMatcher
|
||||
{
|
||||
///// <summary>
|
||||
///// Scenario.
|
||||
|
||||
@@ -32,6 +32,9 @@ namespace WireMock.Serialization
|
||||
Guid = mapping.Guid,
|
||||
Title = mapping.Title,
|
||||
Priority = mapping.Priority,
|
||||
Scenario = mapping.Scenario,
|
||||
WhenStateIs = mapping.ExecutionConditionState,
|
||||
SetStateTo = mapping.NextState,
|
||||
Request = new RequestModel
|
||||
{
|
||||
ClientIP = clientIPMatchers != null && clientIPMatchers.Any() ? new ClientIPModel
|
||||
|
||||
@@ -322,6 +322,13 @@ namespace WireMock.Server
|
||||
if (mappingModel.Priority != null)
|
||||
respondProvider = respondProvider.AtPriority(mappingModel.Priority.Value);
|
||||
|
||||
if (mappingModel.Scenario != null)
|
||||
{
|
||||
respondProvider = respondProvider.InScenario(mappingModel.Scenario);
|
||||
respondProvider = respondProvider.WhenStateIs(mappingModel.WhenStateIs);
|
||||
respondProvider = respondProvider.WillSetStateTo(mappingModel.SetStateTo);
|
||||
}
|
||||
|
||||
respondProvider.RespondWith(responseBuilder);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user