예제 #1
0
        public void Backoff_WithFastFirstEqualToTrue_ResultIsZero()
        {
            // Arrange
            var        delay      = TimeSpan.FromMilliseconds(1);
            const int  retryCount = 3;
            const bool fastFirst  = true;

            // Act
            IEnumerable <TimeSpan> result = Backoff.Constant(delay, retryCount, fastFirst);

            // Assert
            result.Should().NotBeNull();
            result.Should().HaveCount(retryCount);

            bool first = true;

            foreach (TimeSpan timeSpan in result)
            {
                if (first)
                {
                    timeSpan.Should().Be(TimeSpan.Zero);
                    first = false;
                }
                else
                {
                    timeSpan.Should().Be(delay);
                }
            }
        }
예제 #2
0
        public void Backoff_WithRetryCountLessThanZero_ThrowsException()
        {
            // Arrange
            var        delay      = TimeSpan.FromMilliseconds(1);
            const int  retryCount = -1;
            const bool fastFirst  = false;

            // Act
            Action act = () => Backoff.Constant(delay, retryCount, fastFirst);

            // Assert
            act.Should().Throw <ArgumentOutOfRangeException>()
            .And.ParamName.Should().Be("retryCount");
        }
예제 #3
0
        public void Backoff_WithRetryEqualToZero_ResultIsEmpty()
        {
            // Arrange
            var        delay      = TimeSpan.FromMilliseconds(1);
            const int  retryCount = 0;
            const bool fastFirst  = false;

            // Act
            IEnumerable <TimeSpan> result = Backoff.Constant(delay, retryCount, fastFirst);

            // Assert
            result.Should().NotBeNull();
            result.Should().BeEmpty();
        }
예제 #4
0
        public void Backoff_WithDelayLessThanZero_ThrowsException()
        {
            // Arrange
            var        delay      = new TimeSpan(-1);
            const int  retryCount = 3;
            const bool fastFirst  = false;

            // Act
            Action act = () => Backoff.Constant(delay, retryCount, fastFirst);

            // Assert
            act.Should().Throw <ArgumentOutOfRangeException>()
            .And.ParamName.Should().Be("delay");
        }
예제 #5
0
        public void Backoff_ResultIsConstant()
        {
            // Arrange
            var        delay      = TimeSpan.FromMilliseconds(10);
            const int  retryCount = 3;
            const bool fastFirst  = false;

            // Act
            IEnumerable <TimeSpan> result = Backoff.Constant(delay, retryCount, fastFirst);

            // Assert
            result.Should().NotBeNull();
            result.Should().HaveCount(retryCount);

            foreach (TimeSpan timeSpan in result)
            {
                timeSpan.Should().Be(delay);
            }
        }