mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-19 07:43:48 +01:00
44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System.Linq;
|
|
using JetBrains.Annotations;
|
|
using WireMock.Validation;
|
|
|
|
namespace WireMock.Matchers
|
|
{
|
|
/// <summary>
|
|
/// ExactMatcher
|
|
/// </summary>
|
|
/// <seealso cref="IStringMatcher" />
|
|
public class ExactMatcher : IStringMatcher
|
|
{
|
|
private readonly string[] _values;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ExactMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="values">The values.</param>
|
|
public ExactMatcher([NotNull] params string[] values)
|
|
{
|
|
Check.NotNull(values, nameof(values));
|
|
|
|
_values = values;
|
|
}
|
|
|
|
/// <inheritdoc cref="IStringMatcher.IsMatch"/>
|
|
public double IsMatch(string input)
|
|
{
|
|
return MatchScores.ToScore(_values.Select(value => value.Equals(input)));
|
|
}
|
|
|
|
/// <inheritdoc cref="IStringMatcher.GetPatterns"/>
|
|
public string[] GetPatterns()
|
|
{
|
|
return _values;
|
|
}
|
|
|
|
/// <inheritdoc cref="IMatcher.GetName"/>
|
|
public string GetName()
|
|
{
|
|
return "ExactMatcher";
|
|
}
|
|
}
|
|
} |