Пример #1
0
        public void When_task_completes_slow_it_should_fail()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var timer       = new FakeClock();
            var taskFactory = new TaskCompletionSource <int>();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () =>
            {
                Func <Task <int> > func = () => taskFactory.Task;

                func.Should(timer).CompleteWithin(100.Milliseconds());
            };

            timer.RunsIntoTimeout();

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.Should().Throw <XunitException>();
        }
Пример #2
0
        public void When_task_completes_slow_it_should_fail()
        {
            // Arrange
            var timer       = new FakeClock();
            var taskFactory = new TaskCompletionSource <bool>();

            // Act
            Action action = () => taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithin(100.Milliseconds());

            timer.RunsIntoTimeout();

            // Assert
            action.Should().Throw <XunitException>();
        }