コード例 #1
0
        public static void DivManyExample(MathGrpc.IMathServiceClient stub)
        {
            List <DivArgs> divArgsList = new List <DivArgs> {
                new DivArgs.Builder {
                    Dividend = 10, Divisor = 3
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 100, Divisor = 21
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 7, Divisor = 2
                }.Build()
            };

            var recorder = new RecordingObserver <DivReply>();

            var inputs = stub.DivMany(recorder);

            foreach (var input in divArgsList)
            {
                inputs.OnNext(input);
            }
            inputs.OnCompleted();

            Console.WriteLine("DivMany Result: " + string.Join("|", recorder.ToList().Result));
        }
コード例 #2
0
ファイル: MathClientServerTests.cs プロジェクト: yuandy/kythe
        public void DivMany()
        {
            List <DivArgs> divArgsList = new List <DivArgs>
            {
                new DivArgs.Builder {
                    Dividend = 10, Divisor = 3
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 100, Divisor = 21
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 7, Divisor = 2
                }.Build()
            };

            var recorder        = new RecordingObserver <DivReply>();
            var requestObserver = client.DivMany(recorder);

            foreach (var arg in divArgsList)
            {
                requestObserver.OnNext(arg);
            }
            requestObserver.OnCompleted();

            var result = recorder.ToList().Result;

            CollectionAssert.AreEqual(new long[] { 3, 4, 3 }, result.ConvertAll((divReply) => divReply.Quotient));
            CollectionAssert.AreEqual(new long[] { 1, 16, 1 }, result.ConvertAll((divReply) => divReply.Remainder));
        }
コード例 #3
0
        public static async Task DivManyExample(MathGrpc.IMathServiceClient stub)
        {
            var divArgsList = new List <DivArgs>
            {
                new DivArgs.Builder {
                    Dividend = 10, Divisor = 3
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 100, Divisor = 21
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 7, Divisor = 2
                }.Build()
            };

            var recorder = new RecordingObserver <DivReply>();
            var inputs   = stub.DivMany(recorder);

            divArgsList.Subscribe(inputs);
            var result = await recorder.ToList();

            Console.WriteLine("DivMany Result: " + string.Join("|", result));
        }