Пример #1
0
        public async Task should_retry_if_attempts_are_not_exceeded()
        {
            var retry = new Retry(3);

            (await retry.Handle(new Exception(), 1, new FakeMonitoredActivity()).ConfigureAwait(false))
            .ShouldBe(ExceptionAction.Retry);

            (await retry.Handle(new Exception(), 2, new FakeMonitoredActivity()).ConfigureAwait(false))
            .ShouldBe(ExceptionAction.Retry);
        }
Пример #2
0
        public async Task delegates_to_after_max_attempts_when_attempts_are_exceeded()
        {
            var retry = new Retry(3)
            {
                AfterMaxAttempts = new FakeExceptionAction {
                    Result = ExceptionAction.Stop
                }
            };

            (await retry.Handle(new Exception(), 3, new FakeMonitoredActivity()).ConfigureAwait(false))
            .ShouldBe(ExceptionAction.Stop);
        }