Update NotNullOrEmptyMatcher to also implement IStringMatcher (#654)

* Update NotNullOrEmptyMatcher to also implement IStringMatcher

* NotNullOrEmptyMatcher_GetPatterns_Should_Return_EmptyArray

* 24
This commit is contained in:
Stef Heyenrath
2021-10-15 12:59:03 +02:00
committed by GitHub
parent 57cc616aa3
commit 6194f4e460
5 changed files with 58 additions and 8 deletions

View File

@@ -1,4 +1,6 @@
using System.Linq;
using AnyOfTypes;
using WireMock.Models;
namespace WireMock.Matchers
{
@@ -6,7 +8,7 @@ namespace WireMock.Matchers
/// NotNullOrEmptyMatcher
/// </summary>
/// <seealso cref="IObjectMatcher" />
public class NotNullOrEmptyMatcher : IObjectMatcher
public class NotNullOrEmptyMatcher : IObjectMatcher, IStringMatcher
{
/// <inheritdoc cref="IMatcher.Name"/>
public string Name => "NotNullOrEmptyMatcher";
@@ -48,5 +50,19 @@ namespace WireMock.Matchers
return MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(match));
}
/// <inheritdoc cref="IStringMatcher.IsMatch"/>
public double IsMatch(string input)
{
var match = !string.IsNullOrEmpty(input);
return MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(match));
}
/// <inheritdoc cref="IStringMatcher.GetPatterns"/>
public AnyOf<string, StringPattern>[] GetPatterns()
{
return new AnyOf<string, StringPattern>[0];
}
}
}