Beispiel #1
0
        public void TestExponentialBackoffDelays()
        {
            int maxRetries           = 5;
            int delayMilliseconds    = 100;
            int maxDelayMilliseconds = 1000;

            var backoff = new ExponentialBackoff(maxRetries, delayMilliseconds, maxDelayMilliseconds);

            int[] expectedBackoffDelays = { 100, 300, 700, 1000, 1000 };

            int[] resultingBackoffDelays = new int[maxRetries];
            for (int i = 0; i < maxRetries; i++)
            {
                resultingBackoffDelays[i] = backoff.GetNextDelayLength();
            }

            Assert.IsTrue(expectedBackoffDelays.SequenceEqual(resultingBackoffDelays));
        }
Beispiel #2
0
        public void TestExponentialBackoffMaxRetries()
        {
            int maxRetries           = 5;
            int delayMilliseconds    = 1;
            int maxDelayMilliseconds = 1;

            var backoff = new ExponentialBackoff(maxRetries, delayMilliseconds, maxDelayMilliseconds);

            int expectedDelaysCount = maxRetries;

            int resultingDelayCount = 0;

            while (!backoff.MaxReached)
            {
                resultingDelayCount++;
                backoff.GetNextDelayLength();
            }

            Assert.AreEqual(expectedDelaysCount, resultingDelayCount);
        }