public void When_an_action_succeeds_first_time_It_only_tries_once()
        {
            var alwaysSucceedsQuery = new AlwaysSucceedsQuery <object>(new object(), TimeSpan.Zero, TimeSpan.Zero);

            new RetryUntilTimeoutRobustWrapper().Robustly(alwaysSucceedsQuery);

            Assert.That(alwaysSucceedsQuery.Tries, Is.EqualTo(1));
        }
Exemplo n.º 2
0
        public void When_an_action_succeeds_first_time_It_only_tries_once()
        {
            var alwaysSucceedsQuery = new AlwaysSucceedsQuery <object>(new object(), TimeSpan.Zero, TimeSpan.Zero);

            new RetryUntilTimeoutTimingStrategy().Synchronise(alwaysSucceedsQuery);

            Assert.That(alwaysSucceedsQuery.Tries, Is.EqualTo(1));
        }
        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 RetryUntilTimeoutRobustWrapper().Robustly(alwaysSucceedsQuery);

            Assert.That(alwaysSucceedsQuery.Tries, Is.EqualTo(1));
            Assert.That(actualResult, Is.SameAs(expectedResult));
        }
        public void When_the_expected_result_is_never_found_It_returns_the_actual_result_after_timeout()
        {
            var       expectedTimeout = TimeSpan.FromMilliseconds(250);
            const int retryIntervalMS = 70;

            retryInterval = TimeSpan.FromMilliseconds(retryIntervalMS);

            var expectedResult   = new object();
            var unexpectedResult = new object();

            var query = new AlwaysSucceedsQuery <object>(unexpectedResult, expectedResult, expectedTimeout, TimeSpan.FromMilliseconds(retryIntervalMS));

            var actualResult = retryUntilTimeoutRobustWrapper.Robustly(query);

            Assert.That(actualResult, Is.EqualTo(unexpectedResult));
            Assert.That((int)query.LastCall, Is.InRange(expectedTimeout.Milliseconds - retryIntervalMS,
                                                        expectedTimeout.Milliseconds + retryIntervalMS));
        }