mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
* Add another example for Grpc client + mapping * <PackageReference Include="ProtoBufJsonConverter" Version="0.9.0" />
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using Greet;
|
|
using Grpc.Net.Client;
|
|
using Policy2;
|
|
|
|
await TestPolicyAsync();
|
|
// await TestGreeterAsync();
|
|
return;
|
|
|
|
async Task TestGreeterAsync()
|
|
{
|
|
var channel = GrpcChannel.ForAddress("http://localhost:9093/grpc3", new GrpcChannelOptions
|
|
{
|
|
Credentials = Grpc.Core.ChannelCredentials.Insecure
|
|
});
|
|
|
|
var client = new Greeter.GreeterClient(channel);
|
|
|
|
var reply = await client.SayHelloAsync(new HelloRequest { Name = "stef" });
|
|
|
|
Console.WriteLine("Greeting: " + reply.Message);
|
|
}
|
|
|
|
async Task TestPolicyAsync()
|
|
{
|
|
var channel = GrpcChannel.ForAddress("http://localhost:9093/grpc-policy", new GrpcChannelOptions
|
|
{
|
|
Credentials = Grpc.Core.ChannelCredentials.Insecure
|
|
});
|
|
|
|
var client = new PolicyService2.PolicyService2Client(channel);
|
|
|
|
var reply = await client.GetCancellationDetailAsync(new GetCancellationDetailRequest
|
|
{
|
|
Client = new Client
|
|
{
|
|
CorrelationId = "abc"
|
|
}
|
|
});
|
|
|
|
Console.WriteLine("PolicyService2:reply.CancellationName " + reply.CancellationName);
|
|
} |