示例#1
0
        public void IsRetryableExceptionTest()
        {
            TestFixedDelayPolicy policy = new TestFixedDelayPolicy(
                strategy: new NetworkConnectivityErrorDetectionStrategy(),
                maxRetryCount: 3,
                intervalBetweenRetries: TimeSpan.FromMilliseconds(20));

            Assert.False(policy.IsRetryableException(new Exception()));
        }
示例#2
0
        public void FixedDelayPolicyTest()
        {
            TestFixedDelayPolicy policy = new TestFixedDelayPolicy(
                strategy: new NetworkConnectivityErrorDetectionStrategy(),
                maxRetryCount: 3,
                intervalBetweenRetries: TimeSpan.FromMilliseconds(100));
            var  retryState = new RetryStateEx();
            bool shouldRety = policy.InvokeShouldRetryImpl(retryState);

            policy.DoOnIgnoreErrorOccurred(retryState);
            Assert.True(shouldRety);
        }
示例#3
0
        public void FixedDelayPolicyExecuteActionTest()
        {
            TestFixedDelayPolicy policy = new TestFixedDelayPolicy(
                strategy: new NetworkConnectivityErrorDetectionStrategy(),
                maxRetryCount: 3,
                intervalBetweenRetries: TimeSpan.FromMilliseconds(20));

            // execute an action that throws a retry limit exception
            CancellationToken token = new CancellationToken();

            Assert.Equal(policy.ExecuteAction <int>((s) => { throw new RetryLimitExceededException(); }, token), default(int));

            // execute an action that throws a retry limit exeception with an inner exception
            Assert.Throws <Exception>(() =>
            {
                policy.ExecuteAction <int>((s) =>
                {
                    var e = new RetryLimitExceededException("retry", new Exception());
                    throw e;
                });
            });
        }