diff --git a/WireMock.Net.Google.Protobuf.Tests/GrpcPredicateMatcherTests.cs b/WireMock.Net.Google.Protobuf.Tests/GrpcPredicateMatcherTests.cs new file mode 100644 index 0000000..c60b5c2 --- /dev/null +++ b/WireMock.Net.Google.Protobuf.Tests/GrpcPredicateMatcherTests.cs @@ -0,0 +1,28 @@ +using WireMock.Matchers; +using WireMock.Net.Google.Protobuf.Request.Matchers; +using WireMock.Net.Google.Protobuf.Response; +using WireMock.Protobuf.Client; + +namespace WireMock.Net.Google.Protobuf.Tests; + +public class GrpcPredicateMatcherTests +{ + [Test] + public async Task IsMatch_RepeatedCall_Success() + { + // Arrange + var matcher = new GrpcPredicateMatcher( + x => x.Segments.SequenceEqual(["1", "2", "3"]), + MatchBehaviour.AcceptOnMatch); + + var input = new GetGroupsRequestGrpc { Segments = { "1", "2", "3" } }; + var response = ResponseBuilders.Response.Create().WithBodyAsGoogleProtobuf(input); + + // Act + matcher.IsMatch(response.ResponseMessage.BodyData?.BodyAsBytes); + var result = matcher.IsMatch(response.ResponseMessage.BodyData?.BodyAsBytes).IsPerfect(); + + // Assert + await Assert.That(result).IsTrue(); + } +} \ No newline at end of file diff --git a/WireMock.Net.Google.Protobuf/Request/Matchers/GrpcPredicateMatcher.cs b/WireMock.Net.Google.Protobuf/Request/Matchers/GrpcPredicateMatcher.cs index e144366..667ced7 100644 --- a/WireMock.Net.Google.Protobuf/Request/Matchers/GrpcPredicateMatcher.cs +++ b/WireMock.Net.Google.Protobuf/Request/Matchers/GrpcPredicateMatcher.cs @@ -16,7 +16,7 @@ internal sealed class GrpcPredicateMatcher( where TMessage : IMessage, new() { private static readonly TMessage Empty = new(); - private static readonly MessageParser Parser = new(() => Empty); + private static readonly MessageParser Parser = new(() => new()); /// public MatchResult IsMatch(object? input) diff --git a/WireMock.Net.Google.Protobuf/WireMock.Net.Google.Protobuf.csproj b/WireMock.Net.Google.Protobuf/WireMock.Net.Google.Protobuf.csproj index 5d47545..c73f8bd 100644 --- a/WireMock.Net.Google.Protobuf/WireMock.Net.Google.Protobuf.csproj +++ b/WireMock.Net.Google.Protobuf/WireMock.Net.Google.Protobuf.csproj @@ -33,4 +33,8 @@ + + + +