Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions WireMock.Net.Google.Protobuf.Tests/GrpcPredicateMatcherTests.cs
Original file line number Diff line number Diff line change
@@ -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<GetGroupsRequestGrpc>(
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal sealed class GrpcPredicateMatcher<TMessage>(
where TMessage : IMessage<TMessage>, new()
{
private static readonly TMessage Empty = new();
private static readonly MessageParser<TMessage> Parser = new(() => Empty);
private static readonly MessageParser<TMessage> Parser = new(() => new());

/// <inheritdoc />
public MatchResult IsMatch(object? input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
<None Include="../icon.png" Pack="true" Visible="false" PackagePath=""/>
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="WireMock.Net.Google.Protobuf.Tests" />
</ItemGroup>

</Project>