Skip to content

Commit

Permalink
Add unit test "WireMockServer_WithBodyAsProtoBuf_JsonPartialWildcardM…
Browse files Browse the repository at this point in the history
…atcher"
  • Loading branch information
StefH committed Jan 2, 2025
1 parent ab7ce37 commit 1198fea
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion test/WireMock.Net.Tests/Grpc/WireMockServerTests.Grpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,38 @@ message Other {
}
";

[Fact]
public async Task WireMockServer_WithBodyAsProtoBuf_JsonPartialWildcardMatcher()
{
// Arrange
var bytes = Convert.FromBase64String("CgRzdGVm");
var jsonMatcher = new JsonPartialWildcardMatcher(new { name = "*" });

using var server = WireMockServer.Start();

server
.WhenRequest(r => r
.UsingPost()
.WithPath("/grpc/greet.Greeter/SayHello")
.WithBodyAsProtoBuf(ProtoDefinition, "greet.HelloRequest", jsonMatcher)
)
.ThenRespondWith(r => r
.WithTrailingHeader("grpc-status", "0")
);

// Act
var protoBuf = new ByteArrayContent(bytes);
protoBuf.Headers.ContentType = new MediaTypeHeaderValue("application/grpc-web");

var client = server.CreateClient();
var response = await client.PostAsync("/grpc/greet.Greeter/SayHello", protoBuf);

// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);

server.Stop();
}

[Theory]
[InlineData("CgRzdGVm")]
[InlineData("AAAAAAYKBHN0ZWY=")]
Expand Down Expand Up @@ -232,7 +264,7 @@ public async Task WireMockServer_WithBodyAsProtoBuf_MultipleFiles()

using var server = WireMockServer.Start();

var protoFiles = new [] { ProtoDefinitionMain, ProtoDefinitionOther };
var protoFiles = new[] { ProtoDefinitionMain, ProtoDefinitionOther };

server
.Given(Request.Create()
Expand Down

0 comments on commit 1198fea

Please sign in to comment.