mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-09 19:03:52 +02:00
Update WireMockProtoFileResolver and add tests for ProtoBufUtils (#1252)
* Update WireMockProtoFileResolver and add tests for ProtoBufUtils * .
This commit is contained in:
41
test/WireMock.Net.Tests/Grpc/ProtoBufUtilsTests.cs
Normal file
41
test/WireMock.Net.Tests/Grpc/ProtoBufUtilsTests.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
#if PROTOBUF
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Grpc;
|
||||
|
||||
public class ProtoBufUtilsTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task GetProtoBufMessageWithHeader_MultipleProtoFiles()
|
||||
{
|
||||
// Arrange
|
||||
var greet = await ReadProtoFileAsync("greet1.proto");
|
||||
var request = await ReadProtoFileAsync("request.proto");
|
||||
|
||||
// Act
|
||||
var responseBytes = await ProtoBufUtils.GetProtoBufMessageWithHeaderAsync(
|
||||
[greet, request],
|
||||
"greet.HelloRequest",
|
||||
new
|
||||
{
|
||||
name = "hello"
|
||||
}
|
||||
);
|
||||
|
||||
// Assert
|
||||
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAcKBWhlbGxv");
|
||||
}
|
||||
|
||||
private static Task<string> ReadProtoFileAsync(string filename)
|
||||
{
|
||||
return File.ReadAllTextAsync(Path.Combine(Directory.GetCurrentDirectory(), "Grpc", filename));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user