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