Beispiel #1
0
        public void IsTransientException_returns_true()
        {
            var sut       = new TransientFaultDetectionStrategy();
            var fixture   = new Fixture();
            var exception = fixture.Create <Exception>();

            bool actual = sut.IsTransientException(exception);

            actual.Should().BeTrue();
        }
        private async Task PerformRun(
            Func <CancellationToken, Task> operation,
            CancellationToken cancellationToken)
        {
            int retryCount = 0;

Try:
            try
            {
                await operation.Invoke(cancellationToken).ConfigureAwait(false);
            }
            catch (Exception exception)
                when(TransientFaultDetectionStrategy.IsTransientException(exception) && retryCount < MaximumRetryCount)
                {
                    await Task.Delay(RetryIntervalStrategy.GetInterval(retryCount));

                    retryCount++;
                    goto Try;
                }
        }