public void SetUp() { options = new Options { Timeout = TimeSpan.FromMilliseconds(200), RetryInterval = TimeSpan.FromMilliseconds(10) }; _retryUntilTimeoutTimingStrategy = new RetryUntilTimeoutTimingStrategy(); }
public void When_a_query_succeeds_first_time_It_only_tries_once() { var expectedResult = new object(); var alwaysSucceedsQuery = new AlwaysSucceedsQuery <object>(expectedResult, TimeSpan.Zero, TimeSpan.Zero); var actualResult = new RetryUntilTimeoutTimingStrategy().Synchronise(alwaysSucceedsQuery); Assert.That(alwaysSucceedsQuery.Tries, Is.EqualTo(1)); Assert.That(actualResult, Is.SameAs(expectedResult)); }
public void When_a_query_succeeds_first_time_It_only_tries_once() { var expectedResult = new object(); var alwaysSucceedsQuery = new AlwaysSucceedsQuery<object>(expectedResult,TimeSpan.Zero,TimeSpan.Zero); var actualResult = new RetryUntilTimeoutTimingStrategy().Synchronise(alwaysSucceedsQuery); Assert.That(alwaysSucceedsQuery.Tries, Is.EqualTo(1)); Assert.That(actualResult, Is.SameAs(expectedResult)); }
public void When_a_query_throws_a_not_supported_exception_It_does_not_retry() { var retryInterval = TimeSpan.FromMilliseconds(10); var robustness = new RetryUntilTimeoutTimingStrategy(); var query = new AlwaysThrowsQuery<object, NotSupportedException>(new Options{Timeout = TimeSpan.FromMilliseconds(100), RetryInterval = retryInterval}); Assert.Throws<NotSupportedException>(() => robustness.Synchronise(query)); Assert.That(query.Tries, Is.EqualTo(1)); }
public void When_a_query_throws_an_exception_first_time_It_retries() { var expectedResult = new object(); var query = new ThrowsSecondTimeQuery<object>(expectedResult, new Options { Timeout = TimeSpan.FromMilliseconds(100), RetryInterval = TimeSpan.FromMilliseconds(10) }); var actualReturnValue = new RetryUntilTimeoutTimingStrategy().Synchronise(query); Assert.That(query.Tries, Is.EqualTo(2)); Assert.That(actualReturnValue, Is.SameAs(expectedResult)); }
public void When_a_query_throws_an_exception_first_time_It_retries() { var expectedResult = new object(); var query = new ThrowsSecondTimeQuery <object>(expectedResult, new Options { Timeout = TimeSpan.FromMilliseconds(100), RetryInterval = TimeSpan.FromMilliseconds(10) }); var actualReturnValue = new RetryUntilTimeoutTimingStrategy().Synchronise(query); Assert.That(query.Tries, Is.EqualTo(2)); Assert.That(actualReturnValue, Is.SameAs(expectedResult)); }
public void When_a_query_throws_a_not_supported_exception_It_does_not_retry() { var retryInterval = TimeSpan.FromMilliseconds(10); var robustness = new RetryUntilTimeoutTimingStrategy(); var query = new AlwaysThrowsQuery <object, NotSupportedException>(new Options { Timeout = TimeSpan.FromMilliseconds(100), RetryInterval = retryInterval }); Assert.Throws <NotSupportedException>(() => robustness.Synchronise(query)); Assert.That(query.Tries, Is.EqualTo(1)); }
private void When_a_query_always_throws_an_exception_It_retries_until_the_timeout_is_reached(int timeoutMilliseconds, int intervalMilliseconds) { var expectedTimeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); var retryInterval = TimeSpan.FromMilliseconds(intervalMilliseconds); var query = new AlwaysThrowsQuery<object, TestException>(new Options { Timeout = expectedTimeout, RetryInterval = retryInterval }); var retryUntilTimeoutRobustWrapper = new RetryUntilTimeoutTimingStrategy(); try { retryUntilTimeoutRobustWrapper.Synchronise(query); Assert.Fail("Expecting test exception"); } catch (TestException){} Assert.That(query.LastCall, Is.GreaterThan(expectedTimeout.TotalMilliseconds - (retryInterval.Milliseconds + When_waiting.AccuracyMilliseconds))); Assert.That(query.LastCall, Is.LessThan( expectedTimeout.TotalMilliseconds + retryInterval.Milliseconds + When_waiting.AccuracyMilliseconds)); }
private void When_a_query_always_throws_an_exception_It_retries_until_the_timeout_is_reached(int timeoutMilliseconds, int intervalMilliseconds) { var expectedTimeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); var retryInterval = TimeSpan.FromMilliseconds(intervalMilliseconds); var query = new AlwaysThrowsQuery <object, TestException>(new Options { Timeout = expectedTimeout, RetryInterval = retryInterval }); var retryUntilTimeoutRobustWrapper = new RetryUntilTimeoutTimingStrategy(); try { retryUntilTimeoutRobustWrapper.Synchronise(query); Assert.Fail("Expecting test exception"); } catch (TestException) {} Assert.That(query.LastCall, Is.GreaterThan(expectedTimeout.TotalMilliseconds - (retryInterval.Milliseconds + When_waiting.AccuracyMilliseconds))); Assert.That(query.LastCall, Is.LessThan( expectedTimeout.TotalMilliseconds + retryInterval.Milliseconds + When_waiting.AccuracyMilliseconds)); }
public void SetUp() { retryInterval = TimeSpan.FromMilliseconds(10); _retryUntilTimeoutTimingStrategy = new RetryUntilTimeoutTimingStrategy(); }
public void SetUp() { options = new Options {Timeout = TimeSpan.FromMilliseconds(200), RetryInterval = TimeSpan.FromMilliseconds(10)}; _retryUntilTimeoutTimingStrategy = new RetryUntilTimeoutTimingStrategy(); }
public void SetUp() { retryInterval = TimeSpan.FromMilliseconds(10); _retryUntilTimeoutTimingStrategy = new RetryUntilTimeoutTimingStrategy(); }