Example #1
0
 public async Task StructAsyncUnaryCall()
 {
     for (int i = 0; i < ClientRepeatCount; ++i)
     {
         TestRequestStruct  request  = UnitTest1.GetRequestStruct(1);
         TestResponseStruct response = await UnitTest1.Client.StructAsyncUnaryCall(request).ConfigureAwait(false);
     }
 }
Example #2
0
 public void StructBlockingUnaryCall()
 {
     for (int i = 0; i < ClientRepeatCount; ++i)
     {
         TestRequestStruct  request  = UnitTest1.GetRequestStruct(1);
         TestResponseStruct response = UnitTest1.Client.StructBlockingUnaryCall(request);
     }
 }
Example #3
0
        public async Task WriteAllAndReadAsync_Async()
        {
            using (var call = UnitTest1.Client.DuplexStreaming())
            {
                IList <TestResponse> responses = await call.WriteAllAndReadAsync(UnitTest1.GetRequestsAsync(3)).ConfigureAwait(false);

                Assert.AreEqual(6, responses.Count);
            }
        }
Example #4
0
        public async Task StructWriteAllAndFillAsync()
        {
            using (var call = UnitTest1.Client.StructDuplexStreaming())
            {
                List <TestResponseStruct> responses = new List <TestResponseStruct>();
                await call.WriteAllAndFillAsync(UnitTest1.GetRequestStructs(3), responses).ConfigureAwait(false);

                Assert.AreEqual(6, responses.Count);
            }
        }
Example #5
0
 public async Task StructServerStreaming()
 {
     using (var call = UnitTest1.Client.StructServerStreaming(UnitTest1.GetRequestStruct(ServerRepeatCount)))
     {
         while (await call.ResponseStream.MoveNext(System.Threading.CancellationToken.None).ConfigureAwait(false))
         {
             TestResponseStruct response = call.ResponseStream.Current;
         }
     }
 }
Example #6
0
        public async Task StructWriteAllAndForEachAsync()
        {
            void onReponse(TestResponseStruct response)
            {
                Console.WriteLine($"{response.IntValue}, {response.DateTimeValue}");
            }

            using (var call = UnitTest1.Client.StructDuplexStreaming())
            {
                await call.WriteAllAndForEachAsync(UnitTest1.GetRequestStructs(4), (Action <TestResponseStruct>) onReponse).ConfigureAwait(false);
            }
        }
Example #7
0
        public async Task StructDuplexStreaming()
        {
            void onResponse(TestResponseStruct response)
            {
                int value = response.IntValue;
            };

            using (var call = UnitTest1.Client.StructDuplexStreaming())
            {
                await call.WriteAllAndForEachAsync(UnitTest1.GetRequestStructs(ServerRepeatCount), (Action <TestResponseStruct>) onResponse);
            }
        }
Example #8
0
        public async Task WriteAllAndForEachAsync_Async()
        {
            Task onReponse(TestResponse response)
            {
                Console.WriteLine($"{response.IntValue}, {response.DateTimeValue}");
                return(Task.CompletedTask);
            }

            using (var call = UnitTest1.Client.DuplexStreaming())
            {
                await call.WriteAllAndForEachAsync(UnitTest1.GetRequests(4), onReponse).ConfigureAwait(false);
            }
        }
Example #9
0
        public async Task StructClientStreaming()
        {
            using (var call = UnitTest1.Client.StructClientStreaming())
            {
                for (int i = 0; i < ClientRepeatCount; ++i)
                {
                    await call.RequestStream.WriteAsync(UnitTest1.GetRequestStruct(1)).ConfigureAwait(false);
                }
                await call.RequestStream.CompleteAsync().ConfigureAwait(false);

                TestResponseStruct response = await call.ResponseAsync.ConfigureAwait(false);
            }
        }
        public async Task WriteRequestStructsAsync()
        {
            using (var call = UnitTest1.Client.StructClientStreaming())
            {
                await call.WriteRequestsAsync(UnitTest1.GetRequestStructs(3)).ConfigureAwait(false);

                await call.WriteRequestsAsync(UnitTest1.GetRequestStructsAsync(3)).ConfigureAwait(false);

                await call.WriteRequestsAndCompleteAsync(UnitTest1.GetRequestStructs(3)).ConfigureAwait(false);

                TestResponseStruct response = await call.ResponseAsync.ConfigureAwait(false);

                Assert.AreEqual(18, response.IntValue);
            }
        }
        public async Task StructConvertResponse()
        {
            int convert(TestResponseStruct response)
            {
                return(response.IntValue);
            }

            using (var call = UnitTest1.Client.StructClientStreaming().ConvertResponse((Func <TestResponseStruct, int>)convert))
            {
                await call.WriteRequestsAndCompleteAsync(UnitTest1.GetRequestStructs(3)).ConfigureAwait(false);

                int response = await call.ResponseAsync.ConfigureAwait(false);

                Assert.AreEqual(6, response);
            }
        }
Example #12
0
        public async Task StructConvertResponse()
        {
            int convert(TestResponseStruct response)
            {
                return(response.IntValue);
            }

            using (var call = UnitTest1.Client.StructDuplexStreaming().ConvertResponse((Func <TestResponseStruct, int>)convert))
            {
                IList <int> responses = await call.WriteAllAndReadAsync(UnitTest1.GetRequestStructs(3)).ConfigureAwait(false);

                int summary = 0;

                foreach (int value in responses)
                {
                    summary += value;
                }

                Assert.AreEqual(10, summary);
            }
        }