|
|
|
@ -213,11 +213,13 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
|
|
|
|
|
var bodySizes = new List<int> { 27182, 8, 1828, 45904 }.ConvertAll((size) => StreamingInputCallRequest.CreateBuilder().SetPayload(CreateZerosPayload(size)).Build()); |
|
|
|
|
|
|
|
|
|
var call = client.StreamingInputCall(); |
|
|
|
|
using (var call = client.StreamingInputCall()) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.WriteAll(bodySizes); |
|
|
|
|
|
|
|
|
|
var response = await call.Result; |
|
|
|
|
Assert.AreEqual(74922, response.AggregatedPayloadSize); |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -236,14 +238,15 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
(size) => ResponseParameters.CreateBuilder().SetSize(size).Build())) |
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
var call = client.StreamingOutputCall(request); |
|
|
|
|
|
|
|
|
|
using (var call = client.StreamingOutputCall(request)) |
|
|
|
|
{ |
|
|
|
|
var responseList = await call.ResponseStream.ToList(); |
|
|
|
|
foreach (var res in responseList) |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, res.Payload.Type); |
|
|
|
|
} |
|
|
|
|
CollectionAssert.AreEqual(bodySizes, responseList.ConvertAll((item) => item.Payload.Body.Length)); |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -254,8 +257,8 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine("running ping_pong"); |
|
|
|
|
|
|
|
|
|
var call = client.FullDuplexCall(); |
|
|
|
|
|
|
|
|
|
using (var call = client.FullDuplexCall()) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(31415)) |
|
|
|
@ -295,7 +298,7 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
await call.RequestStream.CompleteAsync(); |
|
|
|
|
|
|
|
|
|
Assert.IsFalse(await call.ResponseStream.MoveNext()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -305,12 +308,13 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
Task.Run(async () => |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine("running empty_stream"); |
|
|
|
|
var call = client.FullDuplexCall(); |
|
|
|
|
using (var call = client.FullDuplexCall()) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.CompleteAsync(); |
|
|
|
|
|
|
|
|
|
var responseList = await call.ResponseStream.ToList(); |
|
|
|
|
Assert.AreEqual(0, responseList.Count); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -362,7 +366,8 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
Console.WriteLine("running cancel_after_begin"); |
|
|
|
|
|
|
|
|
|
var cts = new CancellationTokenSource(); |
|
|
|
|
var call = client.StreamingInputCall(cts.Token); |
|
|
|
|
using (var call = client.StreamingInputCall(cts.Token)) |
|
|
|
|
{ |
|
|
|
|
// TODO(jtattermusch): we need this to ensure call has been initiated once we cancel it. |
|
|
|
|
await Task.Delay(1000); |
|
|
|
|
cts.Cancel(); |
|
|
|
@ -376,6 +381,7 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(StatusCode.Cancelled, e.Status.StatusCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -387,8 +393,8 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
Console.WriteLine("running cancel_after_first_response"); |
|
|
|
|
|
|
|
|
|
var cts = new CancellationTokenSource(); |
|
|
|
|
var call = client.FullDuplexCall(cts.Token); |
|
|
|
|
|
|
|
|
|
using (var call = client.FullDuplexCall(cts.Token)) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(31415)) |
|
|
|
@ -409,6 +415,7 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(StatusCode.Cancelled, e.Status.StatusCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
|