The default retry policy
Inheritance: IRetryPolicy
        public void Should_wait_and_execute_retry_action()
        {
            // Arrange
            var are = new AutoResetEvent(false);
            var policy = new DefaultRetryPolicy();

            // Action
            policy.WaitForNextRetry(() => are.Set());
            
            are.WaitOne();

            // Assert
            Assert.AreEqual(1000, policy.DelayTime);
            Assert.IsFalse(policy.IsWaiting);
        }
Esempio n. 2
0
        public void Should_reset_delay_time_to_0()
        {
            // Arrange
            var are = new AutoResetEvent(false);
            var policy = new DefaultRetryPolicy();
            policy.WaitForNextRetry(() => are.Set());
            are.WaitOne();

            // Action
            policy.Reset();

            // Assert
            Assert.AreEqual(0, policy.DelayTime);
            Assert.IsFalse(policy.IsWaiting);
        }
        public void Should_double_delay_time_until_max_delay_value_is_reached()
        {
            // Arrange
            var are = new AutoResetEvent(false);
            var policy = new DefaultRetryPolicy(1000 * 2 /* 2 seconds */);

            // Action
            policy.WaitForNextRetry(() => are.Set());
            are.WaitOne();
            policy.WaitForNextRetry(() => are.Set());
            are.WaitOne();
            policy.WaitForNextRetry(() => are.Set());
            are.WaitOne();

            // Assert
            Assert.AreEqual(2000, policy.DelayTime);
            Assert.IsFalse(policy.IsWaiting);
        }