Add NotNullOrEmptyMatcher (#625)

This commit is contained in:
Stef Heyenrath
2021-08-04 16:22:22 +02:00
committed by GitHub
parent 9d0682bff6
commit 0f99e06acc
11 changed files with 916 additions and 729 deletions

View File

@@ -123,6 +123,22 @@ namespace WireMock.Matchers.Request
private double CalculateMatchScore(IRequestMessage requestMessage, IMatcher matcher)
{
if (matcher is NotNullOrEmptyMatcher notNullOrEmptyMatcher)
{
switch (requestMessage?.BodyData?.DetectedBodyType)
{
case BodyType.Json:
case BodyType.String:
return notNullOrEmptyMatcher.IsMatch(requestMessage.BodyData.BodyAsString);
case BodyType.Bytes:
return notNullOrEmptyMatcher.IsMatch(requestMessage.BodyData.BodyAsBytes);
default:
return MatchScores.Mismatch;
}
}
if (matcher is ExactObjectMatcher exactObjectMatcher)
{
// If the body is a byte array, try to match.