예제 #1
0
        public void SucceedWithExpiration()
        {
            var apiCall = ApiBidirectionalStreamingCall.Create <int, int>(
                callOptions => null,
                CallSettings.FromCallTiming(CallTiming.FromExpiration(Expiration.FromTimeout(TimeSpan.FromSeconds(100)))),
                new BidirectionalStreamingSettings(100),
                new FakeClock());

            Assert.Null(apiCall.Call(null));
        }
        public void FailWithRetry()
        {
            var apiCall = ApiBidirectionalStreamingCall.Create <int, int>(
                callOptions => null,
                CallSettings.FromRetry(new RetrySettings(5, TimeSpan.Zero, TimeSpan.Zero, 1.0, e => false, RetrySettings.RandomJitter)),
                new BidirectionalStreamingSettings(100),
                new FakeClock());

            Assert.Throws <InvalidOperationException>(() => apiCall.Call(null));
        }
예제 #3
0
        public void FailWithRetry()
        {
            var apiCall = ApiBidirectionalStreamingCall.Create <int, int>(
                callOptions => null,
                CallSettings.FromCallTiming(CallTiming.FromRetry(new RetrySettings(
                                                                     new BackoffSettings(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(100), 2.0),
                                                                     new BackoffSettings(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(100), 2.0),
                                                                     Expiration.FromTimeout(TimeSpan.FromSeconds(100))))),
                new BidirectionalStreamingSettings(100),
                new FakeClock());

            Assert.Throws <InvalidOperationException>(() => apiCall.Call(null));
        }
        public void WithLogging()
        {
            var logger  = new MemoryLogger("category");
            var apiCall = ApiBidirectionalStreamingCall.Create <int, int>(
                "BidiStreamingMethod",
                callOptions => null,
                null,
                new BidirectionalStreamingSettings(100),
                new FakeClock()).WithLogging(logger);

            apiCall.Call(null);
            var logs  = logger.ListLogEntries();
            var entry = Assert.Single(logger.ListLogEntries());

            Assert.Contains("BidiStreamingMethod", entry.Message);
        }