| | | 1 | | using System.Linq; |
| | | 2 | | using JetBrains.Annotations; |
| | | 3 | | using WireMock.Validation; |
| | | 4 | | |
| | | 5 | | namespace WireMock.Matchers |
| | | 6 | | { |
| | | 7 | | /// <summary> |
| | | 8 | | /// ExactMatcher |
| | | 9 | | /// </summary> |
| | | 10 | | /// <seealso cref="IStringMatcher" /> |
| | | 11 | | public class ExactMatcher : IStringMatcher |
| | | 12 | | { |
| | | 13 | | private readonly string[] _values; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Initializes a new instance of the <see cref="ExactMatcher"/> class. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="values">The values.</param> |
| | 15 | 19 | | public ExactMatcher([NotNull] params string[] values) |
| | 15 | 20 | | { |
| | 15 | 21 | | Check.HasNoNulls(values, nameof(values)); |
| | | 22 | | |
| | 15 | 23 | | _values = values; |
| | 15 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <inheritdoc cref="IStringMatcher.IsMatch"/> |
| | | 27 | | public double IsMatch(string input) |
| | 5 | 28 | | { |
| | 16 | 29 | | return MatchScores.ToScore(_values.Select(value => value.Equals(input))); |
| | 5 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <inheritdoc cref="IStringMatcher.GetPatterns"/> |
| | | 33 | | public string[] GetPatterns() |
| | 3 | 34 | | { |
| | 3 | 35 | | return _values; |
| | 3 | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <inheritdoc cref="IMatcher.GetName"/> |
| | | 39 | | public string GetName() |
| | 1 | 40 | | { |
| | 1 | 41 | | return "ExactMatcher"; |
| | 1 | 42 | | } |
| | | 43 | | } |
| | | 44 | | } |