public void WaitUntilRetryTimeoutCompletes() { var result = GenericWait.WaitUntilTimeout(() => true, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); Assert.IsTrue(result); result = GenericWait.WaitUntilTimeout(() => false, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); Assert.IsFalse(result); }
public void WaitUntilTimeoutReturnsTrue() { var result = GenericWait.WaitUntilTimeout( () => true, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), false); Assert.IsTrue(result, "Expected Wait to return true"); }
public void WaitUntilTimeoutReturnsString() { var str = "my string"; var result = GenericWait.WaitUntilTimeout( () => str, TimeSpan.FromMilliseconds(500), TimeSpan.FromSeconds(1)); Assert.AreEqual(str, result, "Wait result does not match the expected result of the method"); }
public void WaitUntilTimeoutReturnsStringWithArgument() { var str = "my string"; var result = GenericWait.WaitUntilTimeout( (a) => a, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), str); Assert.AreEqual(str, result, "Passed argument and result do not match"); }
public void WaitUntilTimeoutArgumentsTrue() { var str = "my string"; var result = GenericWait.WaitUntilTimeout( (a) => true, TimeSpan.FromMilliseconds(333), TimeSpan.FromSeconds(1), false, str); Assert.IsTrue(result, "Wait returned incorrect value"); }
public void WaitUntilTimeoutThrowsTimeoutException() { GenericWait.WaitUntilTimeout(() => { Thread.Sleep(TimeSpan.FromSeconds(10)); return("my string"); }, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)); Assert.Fail(); }
public void WaitUntilTimeoutArgumentsThrowsException() { var str = "my string"; GenericWait.WaitUntilTimeout( (a) => { throw new Exception("This method didn't work"); }, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), true, str); Assert.Fail("Method should have thrown an exception"); }
public void WaitUntilTimeoutReturnsStringWithArgumentTimeoutException() { var str = "my string"; GenericWait.WaitUntilTimeout( (a) => { Thread.Sleep(TimeSpan.FromSeconds(10)); return(a); }, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), str); Assert.Fail("Method should have thrown an exception"); }
public void WaitUntilRetryTimeoutTimeoutBeforeMethodCompletion() { var stopwatch = Stopwatch.StartNew(); var result = GenericWait.WaitUntilTimeout(() => { Thread.Sleep(TimeSpan.FromSeconds(10)); return(true); }, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), false); stopwatch.Stop(); Assert.IsFalse(result); Assert.IsTrue(stopwatch.Elapsed < TimeSpan.FromSeconds(10)); }