public void ValidateRetryPolicyCustom() { // Retry up to 5 times. RetryPolicy retry = new RetryPolicyCustom(5); // Retry 4 times. These should allow retry. for (int i = 0; i < 4; i++) { TimeSpan?thisRetryInterval = retry.GetNextRetryInterval(new ServerBusyException(string.Empty), TimeSpan.FromSeconds(60), i + 1); TestUtility.Log("RetryInterval: " + thisRetryInterval); Assert.True(thisRetryInterval.Value.TotalSeconds == 2 + i); } // Retry 5th times. This should not allow retry. TimeSpan?newRetryInterval = retry.GetNextRetryInterval(new ServerBusyException(string.Empty), TimeSpan.FromSeconds(60), 6); TestUtility.Log("RetryInterval: " + newRetryInterval); Assert.True(newRetryInterval == null); }
void ValidateRetryPolicyCustom() { String clientId = "someClientEntity"; // Retry up to 5 times. RetryPolicy retry = new RetryPolicyCustom(5, output); // Retry 4 times. These should allow retry. for (int i = 0; i < 4; i++) { retry.IncrementRetryCount(clientId); TimeSpan?thisRetryInterval = retry.GetNextRetryInterval(clientId, new ServerBusyException(string.Empty), TimeSpan.FromSeconds(60)); Log("RetryInterval: " + thisRetryInterval); Assert.True(thisRetryInterval.Value.TotalSeconds == 2 + i); } // Retry 5th times. This should not allow retry. retry.IncrementRetryCount(clientId); TimeSpan?newRetryInterval = retry.GetNextRetryInterval(clientId, new ServerBusyException(string.Empty), TimeSpan.FromSeconds(60)); Log("RetryInterval: " + newRetryInterval); Assert.True(newRetryInterval == null); }