public void ShouldCompleteInT_WhenFinishBeforeTimeout() { Should.NotThrow(() => Should.CompleteIn(() => { Thread.Sleep(TimeSpan.FromSeconds(1)); return(""); }, TimeSpan.FromSeconds(5))); }
public void ShouldCompleteInT_WhenFinishBeforeTimeout() { Should.NotThrow(() => Should.CompleteIn(() => { Task.Delay(TimeSpan.FromSeconds(1)).Wait(); return(""); }, TimeSpan.FromSeconds(5))); }
public void ShouldCompleteInT_WhenFinishAfterTimeout() { Should.Throw <TimeoutException>(() => Should.CompleteIn(() => { Thread.Sleep(TimeSpan.FromSeconds(2)); return(""); }, TimeSpan.FromSeconds(1))); }
public void ShouldCompleteIn_WhenFinishAfterTimeout() { var ex = Should.Throw <ShouldlyTimeoutException>(() => Should.CompleteIn(() => Task.Delay(TimeSpan.FromSeconds(5)).Wait(), TimeSpan.FromSeconds(1), "Some additional context")); ex.Message.ShouldContainWithoutWhitespace(@" Delegate should complete in 00:00:01 but did not Additional Info: Some additional context"); }
public void ShouldCompleteInTask_WhenFinishAfterTimeout() { var ex = Should.Throw <ShouldlyTimeoutException>(() => Should.CompleteIn( () => Task.Factory.StartNew(() => Thread.Sleep(TimeSpan.FromSeconds(5))), TimeSpan.FromSeconds(1), "Some additional context")); ex.Message.ShouldContainWithoutWhitespace(@" Task should complete in 00:00:01 but did not Additional Info: Some additional context"); }
public void ShouldCompleteInT_WhenFinishAfterTimeout() { var ex = Should.Throw <TimeoutException>(() => Should.CompleteIn(() => { Thread.Sleep(TimeSpan.FromSeconds(5)); return(""); }, TimeSpan.FromSeconds(1), "Some additional context")); ex.Message.ShouldContainWithoutWhitespace(@" Delegate should complete in 00:00:01 but did not Additional Info: Some additional context"); }
public void ShouldCompleteIn_WhenFinishBeforeTimeout() { Should.NotThrow(() => Should.CompleteIn(() => Task.Delay(TimeSpan.FromSeconds(0.5)).Wait(), TimeSpan.FromSeconds(5))); }
public void ShouldCompleteIn_WhenThrowsNonTimeoutException() { Should.Throw <NotImplementedException>(() => Should.CompleteIn(() => { throw new NotImplementedException(); }, TimeSpan.FromSeconds(1))); }
private static void FailingUserCode_CompleteIn() { // Throws a different exception type Should.CompleteIn(Task.Delay(15), TimeSpan.Zero); }
public void ShouldCompleteIn_WhenFinishBeforeTimeout() { Should.NotThrow(() => Should.CompleteIn(() => Thread.Sleep(TimeSpan.FromSeconds(0.5)), TimeSpan.FromSeconds(5))); }