-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update WireMockProtoFileResolver and add tests for ProtoBufUtils
- Loading branch information
Showing
5 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
|
||
import "request.proto"; | ||
|
||
package greet; | ||
|
||
service Greeter { | ||
rpc SayHello (HelloRequest) returns (HelloReply); | ||
} | ||
|
||
message HelloReply { | ||
string message = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// request.proto | ||
syntax = "proto3"; | ||
|
||
package greet; | ||
|
||
message HelloRequest { | ||
string name = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters