public void When_state_exists_It_returns_immediately() { var toTry = new CountTriesAction(options); var retryInterval1 = TimeSpan.FromMilliseconds(10); var until = new AlwaysSucceedsPredicateQuery(true,TimeSpan.Zero,retryInterval1); retryUntilTimeoutRobustWrapper.TryUntil(toTry, until,TimeSpan.FromMilliseconds(20), retryInterval1); Assert.That(toTry.Tries, Is.EqualTo(1)); }
public void When_state_never_exists_It_fails_after_timeout() { var toTry = new CountTriesAction(options); var until = new AlwaysSucceedsPredicateQuery(false, TimeSpan.Zero, options.RetryInterval); var stopwatch = Stopwatch.StartNew(); var timeout1 = TimeSpan.FromMilliseconds(200); Assert.Throws<MissingHtmlException>(() => retryUntilTimeoutRobustWrapper.TryUntil(toTry, until, timeout1, options.RetryInterval)); stopwatch.Stop(); var elapsedMilliseconds = stopwatch.ElapsedMilliseconds; Assert.That(elapsedMilliseconds, Is.InRange(timeout1.TotalMilliseconds - (options.RetryInterval.Milliseconds + When_waiting.AccuracyMilliseconds), timeout1.TotalMilliseconds + (options.RetryInterval.Milliseconds + When_waiting.AccuracyMilliseconds))); }