public void NoErrorDelayIsSameAsSlotDelay() { var manager = new BackoffLogicManager(TimeSpan.Zero); manager.GetBackOffTimeInterval(string.Empty); Assert.Equal(TimeSpan.FromSeconds(10), manager.CurrentDelay); }
public void AssertIfDateParseErrorCausesDefaultDelay() { var manager = new BackoffLogicManager(TimeSpan.Zero); manager.GetBackOffTimeInterval("no one can parse me"); Assert.Equal(TimeSpan.FromSeconds(10), manager.CurrentDelay); }
public void RetryAfterFromHeadersHasMorePriorityThanExponentialRetry() { var manager = new BackoffLogicManager(TimeSpan.Zero); manager.GetBackOffTimeInterval(DateTimeOffset.UtcNow.AddSeconds(30).ToString("O")); Xunit.Assert.InRange(manager.CurrentDelay, TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(30)); }
public void RetryAfterOlderThanNowCausesDefaultDelay() { // An old date string retryAfterDateString = DateTime.Now.AddMinutes(-1).ToString("R", CultureInfo.InvariantCulture); var manager = new BackoffLogicManager(TimeSpan.Zero); manager.GetBackOffTimeInterval(retryAfterDateString); Assert.Equal(TimeSpan.FromSeconds(10), manager.CurrentDelay); }
public void UpperBoundOfDelayIsMaxDelay() { var manager = new BackoffLogicManager(TimeSpan.Zero, TimeSpan.Zero); PrivateObject wrapper = new PrivateObject(manager); wrapper.SetField("consecutiveErrors", int.MaxValue); manager.GetBackOffTimeInterval(string.Empty); Assert.InRange(manager.CurrentDelay, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(3600)); }