Example #1
0
        public void InfiniteDeadline()
        {
            helper.UnaryHandler = new UnaryServerMethod <string, string>((request, context) =>
            {
                Assert.AreEqual(DateTime.MaxValue, context.Deadline);
                return(Task.FromResult("PASS"));
            });

            // no deadline specified, check server sees infinite deadline
            Assert.AreEqual("PASS", Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "abc"));

            // DateTime.MaxValue deadline specified, check server sees infinite deadline
            Assert.AreEqual("PASS", Calls.BlockingUnaryCall(helper.CreateUnaryCall(new CallOptions(deadline: DateTime.MaxValue)), "abc"));
        }
Example #2
0
        // Test attribute commented out to prevent running as part of the default test suite.
        //[Test]
        //[Category("Performance")]
        public void UnaryCallPerformance()
        {
            var profiler = new BasicProfiler();
            Profilers.SetForCurrentThread(profiler);

            helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) =>
            {
                return request;
            });

            var callDetails = helper.CreateUnaryCall();
            for(int i = 0; i < 3000; i++)
            {
                Calls.BlockingUnaryCall(callDetails, "ABC");
            }

            profiler.Reset();

            for(int i = 0; i < 3000; i++)
            {
                Calls.BlockingUnaryCall(callDetails, "ABC");
            }
            profiler.Dump("latency_trace_csharp.txt");
        }
Example #3
0
        public async Task UnaryCall()
        {
            helper.UnaryHandler = new UnaryServerMethod <string, string>((request, context) =>
            {
                return(Task.FromResult(request));
            });

            Assert.AreEqual("ABC", Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "ABC"));

            Assert.AreEqual("ABC", await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "ABC"));
        }