mirror of https://github.com/dapr/dotnet-sdk.git
fixes for getting the samples to work (#570)
* fixes for getting the samples to work * add ut
This commit is contained in:
parent
aa41915e38
commit
7f9d23cdf5
|
|
@ -20,21 +20,21 @@ namespace Samples.Client
|
|||
{
|
||||
using var client = new DaprClientBuilder().Build();
|
||||
|
||||
Console.WriteLine("Invoking grpc balance");
|
||||
var request = new GetAccountRequest() { Id = "17", };
|
||||
var account = await client.InvokeMethodGrpcAsync<GetAccountRequest, Account>("grpcsample", "getaccount", request, cancellationToken);
|
||||
Console.WriteLine($"Received grpc balance {account.Balance}");
|
||||
|
||||
Console.WriteLine("Invoking grpc deposit");
|
||||
var data = new GrpcServiceSample.Generated.Transaction() { Id = "17", Amount = 99 };
|
||||
account = await client.InvokeMethodGrpcAsync<Transaction, Account>("grpcsample", "deposit", data, cancellationToken);
|
||||
var deposit = new GrpcServiceSample.Generated.Transaction() { Id = "17", Amount = 99 };
|
||||
var account = await client.InvokeMethodGrpcAsync<GrpcServiceSample.Generated.Transaction, Account>("grpcsample", "deposit", deposit, cancellationToken);
|
||||
Console.WriteLine("Returned: id:{0} | Balance:{1}", account.Id, account.Balance);
|
||||
Console.WriteLine("Completed grpc deposit");
|
||||
|
||||
Console.WriteLine("Invoking grpc withdraw");
|
||||
var withdraw = new Transaction() { Id = "17", Amount = 10, };
|
||||
await client.InvokeMethodGrpcAsync("grpcsample", "withdraw", data, cancellationToken);
|
||||
var withdraw = new GrpcServiceSample.Generated.Transaction() { Id = "17", Amount = 10, };
|
||||
await client.InvokeMethodGrpcAsync("grpcsample", "withdraw", withdraw, cancellationToken);
|
||||
Console.WriteLine("Completed grpc withdraw");
|
||||
|
||||
Console.WriteLine("Invoking grpc balance");
|
||||
var request = new GetAccountRequest() { Id = "17", };
|
||||
account = await client.InvokeMethodGrpcAsync<GetAccountRequest, Account>("grpcsample", "getaccount", request, cancellationToken);
|
||||
Console.WriteLine($"Received grpc balance {account.Balance}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ namespace Dapr.Client
|
|||
if (content != null)
|
||||
{
|
||||
envelope.Data = content;
|
||||
envelope.DataContentType = "application/json";
|
||||
}
|
||||
|
||||
if (metadata != null)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ namespace Dapr.Client.Test
|
|||
var request = await GrpcUtils.GetRequestFromRequestMessageAsync<PublishEventRequest>(entry.Request);
|
||||
var jsonFromRequest = request.Data.ToStringUtf8();
|
||||
|
||||
request.DataContentType.Should().Be("application/json");
|
||||
request.PubsubName.Should().Be(TestPubsubName);
|
||||
request.Topic.Should().Be("test");
|
||||
jsonFromRequest.Should().Be(JsonSerializer.Serialize(publishData, daprClient.JsonSerializerOptions));
|
||||
|
|
@ -63,6 +64,7 @@ namespace Dapr.Client.Test
|
|||
var request = await GrpcUtils.GetRequestFromRequestMessageAsync<PublishEventRequest>(entry.Request);
|
||||
var jsonFromRequest = request.Data.ToStringUtf8();
|
||||
|
||||
request.DataContentType.Should().Be("application/json");
|
||||
request.PubsubName.Should().Be(TestPubsubName);
|
||||
request.Topic.Should().Be("test");
|
||||
jsonFromRequest.Should().Be(JsonSerializer.Serialize(publishData, daprClient.JsonSerializerOptions));
|
||||
|
|
|
|||
Loading…
Reference in New Issue