// Copyright © WireMock.Net namespace WireMock.Matchers; /// /// MatchBehaviourHelper /// internal static class MatchBehaviourHelper { /// /// Converts the specified match behaviour and match value to a new match value. /// /// if AcceptOnMatch --> return match (default) /// if RejectOnMatch and match = 0.0 --> return 1.0 /// if RejectOnMatch and match = 0.? --> return 0.0 /// if RejectOnMatch and match = 1.0 --> return 0.0 /// /// The match behaviour. /// The match. /// match value internal static double Convert(MatchBehaviour matchBehaviour, double match) { if (matchBehaviour == MatchBehaviour.AcceptOnMatch) { return match; } return match <= MatchScores.Tolerance ? MatchScores.Perfect : MatchScores.Mismatch; } /// /// Converts the specified match behaviour and match result to a new match result value. /// /// The match behaviour. /// The match result. /// match result internal static MatchResult Convert(MatchBehaviour matchBehaviour, MatchResult result) { return matchBehaviour == MatchBehaviour.AcceptOnMatch ? result : MatchResult.From(result.Name, Convert(matchBehaviour, result.Score), result.Exception); } }