mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-16 07:06:54 +01:00
* Create WireMock.Net.ProtoBuf project * ok * Update Directory.Build.props Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
// 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
|
|
{
|
|
private static readonly IProtoBufUtils ProtoBufUtils = new ProtoBufUtils();
|
|
|
|
[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 |