| | | 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="IMatcher" /> |
| | | 11 | | public class ExactMatcher : IMatcher |
| | | 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> |
| | 7 | 19 | | public ExactMatcher([NotNull] params string[] values) |
| | 7 | 20 | | { |
| | 7 | 21 | | Check.NotNull(values, nameof(values)); |
| | | 22 | | |
| | 7 | 23 | | _values = values; |
| | 7 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Determines whether the specified input is match. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <param name="input">The input.</param> |
| | | 30 | | /// <returns>A value between 0.0 - 1.0 of the similarity.</returns> |
| | | 31 | | public double IsMatch(string input) |
| | 3 | 32 | | { |
| | 7 | 33 | | return MatchScores.ToScore(_values.Select(value => value.Equals(input))); |
| | 3 | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets the value. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <returns>Patterns</returns> |
| | | 40 | | public string[] GetPatterns() |
| | 0 | 41 | | { |
| | 0 | 42 | | return _values; |
| | 0 | 43 | | } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Gets the name. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <returns>Name</returns> |
| | | 49 | | public string GetName() |
| | 0 | 50 | | { |
| | 0 | 51 | | return "ExactMatcher"; |
| | 0 | 52 | | } |
| | | 53 | | } |
| | | 54 | | } |