public async Task StructForEachAsync_Async()
        {
            TestRequestStruct request = new TestRequestStruct {
                IntValue = 3, DateTimeValue = DateTime.UtcNow
            };

            int count = 0;

            Task onResponse(TestResponseStruct response)
            {
                Console.WriteLine($"{response.IntValue}, {response.DateTimeValue}");
                ++count;
                return(Task.CompletedTask);
            }

            using (var call = UnitTest1.Client.StructServerStreaming(request))
            {
                await call.ForEachAsync((Func <TestResponseStruct, Task>) onResponse).ConfigureAwait(false);

                Assert.AreEqual(3, count);
            }
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public AsyncServerStreamingCall <TestResponseStruct> StructServerStreaming(TestRequestStruct request)
 {
     return(CallInvoker.StructAsyncServerStreamingCall(TestRpcMethods.ReceiveResponsesStruct, "", new CallOptions(), request));
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <TestResponseStruct> StructAsyncUnaryCall(TestRequestStruct request)
 {
     return(await CallInvoker.StructAsyncUnaryCall(TestRpcMethods.GetResponseStruct, "", new CallOptions(), request));
 }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request"></param>
 public TestResponseStruct StructBlockingUnaryCall(TestRequestStruct request)
 {
     return(CallInvoker.StructBlockingUnaryCall(TestRpcMethods.GetResponseStruct, "", new CallOptions(), request));
 }
Exemple #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public Task <TestResponseStruct> GetResponseStruct(TestRequestStruct request, ServerCallContext context)
 {
     return(Task.FromResult(new TestResponseStruct {
         IntValue = request.IntValue * -1, DateTimeValue = request.DateTimeValue.AddDays(1)
     }));
 }