コード例 #1
0
        public static async Task DependendRequestsExample(Math.IMathClient client)
        {
            var numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            Num sum;

            using (var sumCall = client.Sum())
            {
                await sumCall.RequestStream.WriteAll(numbers);

                sum = await sumCall.Result;
            }

            DivReply result = await client.DivAsync(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numbers.Count }.Build());

            Console.WriteLine("Avg Result: " + result);
        }
コード例 #2
0
        public async Task DivAsync()
        {
            DivReply response = await client.DivAsync(new DivArgs { Dividend = 10, Divisor = 3 });

            Assert.AreEqual(3, response.Quotient);
            Assert.AreEqual(1, response.Remainder);
        }
コード例 #3
0
        public static void DivExample(Math.IMathClient client)
        {
            DivReply result = client.Div(new DivArgs.Builder {
                Dividend = 10, Divisor = 3
            }.Build());

            Console.WriteLine("Div Result: " + result);
        }
コード例 #4
0
        public static void DivExample(MathGrpc.IMathServiceClient stub)
        {
            DivReply result = stub.Div(new DivArgs.Builder {
                Dividend = 10, Divisor = 3
            }.Build());

            Console.WriteLine("Div Result: " + result);
        }
コード例 #5
0
        public void Div2()
        {
            DivReply response = client.Div(new DivArgs {
                Dividend = 0, Divisor = 1
            });

            Assert.AreEqual(0, response.Quotient);
            Assert.AreEqual(0, response.Remainder);
        }
コード例 #6
0
        public void Div1()
        {
            DivReply response = client.Div(new DivArgs {
                Dividend = 10, Divisor = 3
            });

            Assert.AreEqual(3, response.Quotient);
            Assert.AreEqual(1, response.Remainder);
        }
コード例 #7
0
        public static async Task DivAsyncExample(Math.IMathClient client)
        {
            Task <DivReply> resultTask = client.DivAsync(new DivArgs.Builder {
                Dividend = 4, Divisor = 5
            }.Build());
            DivReply result = await resultTask;

            Console.WriteLine("DivAsync Result: " + result);
        }
コード例 #8
0
        public static void DivAsyncWithCancellationExample(MathGrpc.IMathServiceClient stub)
        {
            Task <DivReply> call = stub.DivAsync(new DivArgs.Builder {
                Dividend = 4, Divisor = 5
            }.Build());
            DivReply result = call.Result;

            Console.WriteLine(result);
        }
コード例 #9
0
        public static async Task DivAsyncWithCancellationExample(Math.IMathClient stub)
        {
            Task <DivReply> resultTask = stub.DivAsync(new DivArgs.Builder {
                Dividend = 4, Divisor = 5
            }.Build());
            DivReply result = await resultTask;

            Console.WriteLine(result);
        }
コード例 #10
0
        public static async Task DivAsyncExample(MathGrpc.IMathServiceClient stub)
        {
            Task <DivReply> resultTask = stub.DivAsync(new DivArgs.Builder {
                Dividend = 4, Divisor = 5
            }.Build());
            DivReply result = await resultTask;

            Console.WriteLine("DivAsync Result: " + result);
        }
コード例 #11
0
        public void ClientBaseBlockingUnaryCallWithCallOptionsCallCanBeMocked()
        {
            var mockClient = new Moq.Mock <Math.MathClient>();

            var expected = new DivReply();

            mockClient.Setup(m => m.Div(Moq.It.IsAny <DivArgs>(), Moq.It.IsAny <CallOptions>())).Returns(expected);
            Assert.AreSame(expected, mockClient.Object.Div(new DivArgs(), new CallOptions()));
        }
コード例 #12
0
ファイル: MathClientServerTests.cs プロジェクト: wfarr/grpc
        public void DivAsync()
        {
            DivReply response = client.DivAsync(new DivArgs.Builder {
                Dividend = 10, Divisor = 3
            }.Build()).Result;

            Assert.AreEqual(3, response.Quotient);
            Assert.AreEqual(1, response.Remainder);
        }
コード例 #13
0
 public void DivAsync()
 {
     Task.Run(async() =>
     {
         DivReply response = await client.DivAsync(new DivArgs.Builder {
             Dividend = 10, Divisor = 3
         }.Build());
         Assert.AreEqual(3, response.Quotient);
         Assert.AreEqual(1, response.Remainder);
     }).Wait();
 }
コード例 #14
0
 public void DivByZero()
 {
     try
     {
         DivReply response = client.Div(new DivArgs.Builder {
             Dividend = 0, Divisor = 0
         }.Build());
         Assert.Fail();
     }
     catch (RpcException e)
     {
         Assert.AreEqual(StatusCode.Unknown, e.Status.StatusCode);
     }
 }
コード例 #15
0
        public static async Task DependendRequestsExample(MathGrpc.IMathServiceClient stub)
        {
            var numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            var clientStreamingResult = stub.Sum();

            numbers.Subscribe(clientStreamingResult.Inputs);
            Num sum = await clientStreamingResult.Task;

            DivReply result = await stub.DivAsync(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numbers.Count }.Build());

            Console.WriteLine("Avg Result: " + result);
        }