示例#1
0
            public void NoErrorDelayIsSameAsSlotDelay()
            {
                var manager = new BackoffLogicManager(TimeSpan.Zero);

                manager.ScheduleRestore(string.Empty, () => null);
                Assert.Equal(TimeSpan.FromSeconds(10), manager.CurrentDelay);
            }
示例#2
0
            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);
            }
示例#3
0
            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));
            }
示例#4
0
            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));
            }
示例#5
0
            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);
            }