using JetBrains.Annotations; namespace WireMock.Matchers.Request { /// /// The scenario and state matcher. /// internal class RequestMessageScenarioAndStateMatcher : IRequestMatcher { /// /// Execution state condition for the current mapping. /// [CanBeNull] private readonly string _executionConditionState; /// /// The next state which will be signaled after the current mapping execution. /// In case the value is null state will not be changed. /// [CanBeNull] private readonly string _nextState; /// /// Initializes a new instance of the class. /// /// The next state. /// Execution state condition for the current mapping. public RequestMessageScenarioAndStateMatcher([CanBeNull] string nextState, [CanBeNull] string executionConditionState) { _nextState = nextState; _executionConditionState = executionConditionState; } /// public double GetMatchingScore(IRequestMessage requestMessage, IRequestMatchResult requestMatchResult) { double score = IsMatch(); return requestMatchResult.AddScore(GetType(), score); } private double IsMatch() { return Equals(_executionConditionState, _nextState) ? MatchScores.Perfect : MatchScores.Mismatch; } } }