public void IsRetryableExceptionTest() { TestFixedDelayPolicy policy = new TestFixedDelayPolicy( strategy: new NetworkConnectivityErrorDetectionStrategy(), maxRetryCount: 3, intervalBetweenRetries: TimeSpan.FromMilliseconds(20)); Assert.False(policy.IsRetryableException(new Exception())); }
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); }
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; }); }); }