예제 #1
0
        public void CountBasedFixedDelayRetry_Last_Retry_Delay_Is_Zero()
        {
            var      testRetryPolicy = new CountBasedFixedDelayRetryPolicy(1, TimeSpan.FromSeconds(1));
            TimeSpan lastDelay       = TimeSpan.MaxValue;

            while (testRetryPolicy.ShouldExecute())
            {
                lastDelay = testRetryPolicy.GetNextDelay();
            }
            Assert.AreEqual(TimeSpan.Zero, lastDelay);
        }
예제 #2
0
        public void CountBasedFixedDelayRetry_Attempts_MaxCount_Times()
        {
            var testRetryPolicy = new CountBasedFixedDelayRetryPolicy(3, TimeSpan.Zero);
            int attempts        = 0;

            while (testRetryPolicy.ShouldExecute())
            {
                attempts++;
            }
            Assert.AreEqual(3, attempts);
        }
예제 #3
0
        public void CountBasedFixedDelayRetry_Non_Last_Retry_Delay_Is_Fixed()
        {
            TimeSpan fixedDelay      = TimeSpan.FromSeconds(23);
            var      testRetryPolicy = new CountBasedFixedDelayRetryPolicy(3, fixedDelay);
            int      attemptNumber   = 1;
            TimeSpan nextDelay       = TimeSpan.MaxValue;

            while (testRetryPolicy.ShouldExecute())
            {
                nextDelay = testRetryPolicy.GetNextDelay();
                if (attemptNumber < 3)
                {
                    Assert.AreEqual(fixedDelay, nextDelay);
                }
                attemptNumber++;
            }
            Assert.AreEqual(TimeSpan.Zero, nextDelay);
        }