public static async Task RunServerStreamingAsync(TestService.ITestServiceClient client) { Console.WriteLine("running server_streaming"); var bodySizes = new List <int> { 31415, 9, 2653, 58979 }; var request = new StreamingOutputCallRequest { ResponseType = PayloadType.COMPRESSABLE, ResponseParameters = { bodySizes.ConvertAll((size) => new ResponseParameters { Size = size }) } }; using (var call = client.StreamingOutputCall(request)) { var responseList = await call.ResponseStream.ToListAsync(); 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!"); }
public static void RunServerStreaming(TestService.ITestServiceClient client) { Task.Run(async() => { Console.WriteLine("running server_streaming"); var bodySizes = new List <int> { 31415, 9, 2653, 58979 }; var request = StreamingOutputCallRequest.CreateBuilder() .SetResponseType(PayloadType.COMPRESSABLE) .AddRangeResponseParameters(bodySizes.ConvertAll( (size) => ResponseParameters.CreateBuilder().SetSize(size).Build())) .Build(); 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(); }