Ejemplo n.º 1
0
        public void Should_allow_to_retry_after_few_errors(int errors)
        {
            var sut = new RetryWindow(TimeSpan.FromSeconds(1), 5, clock);

            for (var i = 0; i < errors; i++)
            {
                Assert.True(sut.CanRetryAfterFailure());
            }
        }
Ejemplo n.º 2
0
        public void Should_allow_to_retry_after_few_errors_in_window(int errors)
        {
            var sut = new RetryWindow(TimeSpan.FromSeconds(1), WindowSize);
            var now = DateTime.UtcNow;

            for (var i = 0; i < errors; i++)
            {
                Assert.True(sut.CanRetryAfterFailure(now.AddMilliseconds(i * 300)));
            }
        }
Ejemplo n.º 3
0
        public void Should_allow_to_retry_after_reset()
        {
            var sut = new RetryWindow(TimeSpan.FromSeconds(1), 5);

            for (var i = 0; i < 5 * 2; i++)
            {
                sut.CanRetryAfterFailure();
            }

            sut.Reset();

            Assert.True(sut.CanRetryAfterFailure());
        }
Ejemplo n.º 4
0
        public void Should_allow_to_retry_after_few_errors_in_window(int errors)
        {
            var sut = new RetryWindow(TimeSpan.FromSeconds(1), 5, clock);

            var now = SystemClock.Instance.GetCurrentInstant();

            A.CallTo(() => clock.GetCurrentInstant())
            .ReturnsLazily(() => now);

            for (var i = 0; i < errors; i++)
            {
                now = now.Plus(Duration.FromMilliseconds(300));

                Assert.True(sut.CanRetryAfterFailure());
            }
        }
Ejemplo n.º 5
0
        public void Should_not_allow_to_retry_after_many_errors(int errors)
        {
            var sut = new RetryWindow(TimeSpan.FromSeconds(1), 5, clock);

            for (var i = 0; i < 5; i++)
            {
                Assert.True(sut.CanRetryAfterFailure());
            }

            var remaining = errors - 5;

            for (var i = 0; i < remaining; i++)
            {
                Assert.False(sut.CanRetryAfterFailure());
            }
        }
Ejemplo n.º 6
0
        public void Should_not_allow_to_retry_after_many_errors(int errors)
        {
            var sut = new RetryWindow(TimeSpan.FromSeconds(1), WindowSize);
            var now = DateTime.UtcNow;

            for (var i = 0; i < WindowSize; i++)
            {
                Assert.True(sut.CanRetryAfterFailure(now));
            }

            var remaining = errors - WindowSize;

            for (var i = 0; i < remaining; i++)
            {
                Assert.False(sut.CanRetryAfterFailure(now));
            }
        }