public void When_task_completes_slow_async_it_should_fail() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var timer = new TestingTimer(); var taskFactory = new TaskCompletionSource <int>(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Func <Task> action = () => { Func <Task <int> > func = () => taskFactory.Task; return(func.Should(timer).CompleteWithinAsync(100.Milliseconds())); }; timer.RunsIntoTimeout(); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- action.Should().Throw <XunitException>(); }
public void When_task_completes_slow_it_should_fail() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var timer = new TestingTimer(); var taskFactory = new TaskCompletionSource <bool>(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action action = () => taskFactory.Awaiting(t => t.Task).Should(timer).CompleteWithin(100.Milliseconds()); timer.RunsIntoTimeout(); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- action.Should().Throw <XunitException>(); }