public async void RetryAsyncFailAction()
        {
            // Arrange & Act.
            var result = await Retrier.Init()
                         .WithNumberOfRetries(1)
                         .InvokeAsync(async() => await FakeService.DivideByZeroExceptionAsync());

            // Assert.
            Assert.False(result.Successful);
            Assert.Equal(2, result.RetryInfo.Executions);
            Assert.IsType <DivideByZeroException>(result.RetryInfo.Exceptions.FirstOrDefault());
        }
Esempio n. 2
0
        public void RetryAsyncFallbackThatFails()
        {
            // Arrange & Act.
            var result = Retrier.Init()
                         .WithNumberOfRetries(1)
                         .WithMsWaitOf(0)
                         .Invoke(FakeService.OutOfMemory)
                         .WithFallBackAsync(async() => await FakeService.DivideByZeroExceptionAsync())
                         .WaitForValue();

            // Assert.
            Assert.Equal(0, result.Result);
            Assert.Equal(3, result.RetryInfo.Executions);
            Assert.False(result.Successful);
            Assert.IsType <DivideByZeroException>(result.FallBackException);
            Assert.IsType <OutOfMemoryException>(result.RetryInfo.Exceptions.FirstOrDefault());
        }