using System.Linq; using JetBrains.Annotations; using WireMock.Validation; namespace WireMock.Matchers { /// /// ExactMatcher /// /// public class ExactMatcher : IStringMatcher { private readonly string[] _values; /// public MatchBehaviour MatchBehaviour { get; } /// /// Initializes a new instance of the class. /// /// The values. public ExactMatcher([NotNull] params string[] values) : this(MatchBehaviour.AcceptOnMatch, values) { } /// /// Initializes a new instance of the class. /// /// The match behaviour. /// The values. public ExactMatcher(MatchBehaviour matchBehaviour, [NotNull] params string[] values) { Check.HasNoNulls(values, nameof(values)); _values = values; MatchBehaviour = matchBehaviour; } /// public double IsMatch(string input) { if (_values.Length == 1) { return MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(_values[0] == input)); } return MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(_values.Contains(input))); } /// public string[] GetPatterns() { return _values; } /// public string Name => "ExactMatcher"; } }