Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
 public void StructBlockingUnaryCall()
 {
     for (int i = 0; i < ClientRepeatCount; ++i)
     {
         TestRequestStruct  request  = UnitTest1.GetRequestStruct(1);
         TestResponseStruct response = UnitTest1.Client.StructBlockingUnaryCall(request);
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }