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));
        }
Exemple #2
0
        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_the_expected_result_is_found_It_returns_the_expected_result_immediately()
        {
            var expectedResult = new object();

            var actualResult = _retryUntilTimeoutTimingStrategy.Synchronise(new AlwaysSucceedsQuery <object>(expectedResult, expectedResult, TimeSpan.FromMilliseconds(200), retryInterval));

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
        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));

        }
Exemple #5
0
        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));
        }