Esempio n. 1
0
        public void Should_return_constant_delay()
        {
            var delay          = TimeSpan.FromMilliseconds(10);
            var recoveryPolicy = RecoveryPolicyFactory.ConstantBackoff(delay);
            var result         = RecoveryPolicyUtils.GetDelays(recoveryPolicy);

            Assert.Equal(new double[] { 10, 10, 10, 10, 10 }, result);
        }
Esempio n. 2
0
        public void Should_return_zero_delay_for_first_attempt_when_fast_first_flag_enabled()
        {
            var delay          = TimeSpan.FromMilliseconds(10);
            var recoveryPolicy = RecoveryPolicyFactory.ConstantBackoff(delay, fastFirst: true);
            var result         = RecoveryPolicyUtils.GetDelays(recoveryPolicy);

            Assert.Equal(new double[] { 0, 10, 10, 10, 10 }, result);
        }
        public void Should_return_delays_in_a_linear_manner(double initialDelayMilliseconds, double factor, double[] delays)
        {
            var initialDelay   = TimeSpan.FromMilliseconds(initialDelayMilliseconds);
            var recoveryPolicy = RecoveryPolicyFactory.LinearBackoff(initialDelay, factor: factor);
            var result         = RecoveryPolicyUtils.GetDelays(recoveryPolicy);

            Assert.Equal(delays, result);
        }
        public void Should_return_constant_delay_when_factor_is_zero_and_fast_first_flag_enabled()
        {
            var initialDelay   = TimeSpan.FromMilliseconds(10);
            var factor         = 0;
            var recoveryPolicy = RecoveryPolicyFactory.LinearBackoff(initialDelay, factor: factor, fastFirst: true);
            var result         = RecoveryPolicyUtils.GetDelays(recoveryPolicy);

            Assert.Equal(new double[] { 0, 10, 10, 10, 10 }, result);
        }
        public void Should_not_return_delay_longer_than_specified_max_delay()
        {
            var initialDelay   = TimeSpan.FromMilliseconds(10);
            var maxDelay       = TimeSpan.FromMilliseconds(90);
            var factor         = 3;
            var recoveryPolicy = RecoveryPolicyFactory.LinearBackoff(initialDelay, maxDelay, factor: factor);
            var result         = RecoveryPolicyUtils.GetDelays(recoveryPolicy);

            Assert.Equal(new double[] { 10, 40, 70, 90, 90 }, result);
        }