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()); } }
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))); } }
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()); }
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()); } }
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()); } }
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)); } }