public void When_no_exception_should_be_thrown_for_async_func_after_wait_time_and_none_was_it_should_not_throw()
        {
            // Arrange
            var waitTime     = 6.Seconds();
            var pollInterval = 10.Milliseconds();

            var clock = new FakeClock();
            var timer = clock.StartTimer();

            clock.Delay(waitTime);

            Func <Task> throwShorterThanWaitTime = async() =>
            {
                if (timer.Elapsed <= waitTime.Divide(12))
                {
                    throw new ArgumentException("An exception was forced");
                }

                await Task.Delay(0);
            };

            // Act
            Func <Task> act = () => throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);

            // Assert
            act.Should().NotThrow();
        }
        public async Task When_no_exception_should_be_thrown_async_on_UI_thread_after_wait_time_and_none_was_it_should_not_throw()
        {
            // Arrange
            var waitTime     = 6.Seconds();
            var pollInterval = 10.Milliseconds();

            var clock = new FakeClock();
            var timer = clock.StartTimer();

            clock.Delay(waitTime);

            Func <Task <int> > throwShorterThanWaitTime = async() =>
            {
                if (timer.Elapsed <= waitTime.Divide(12))
                {
                    throw new ArgumentException("An exception was forced");
                }

                await Task.Yield();

                return(42);
            };

            // Act
            Func <Task> act = async() =>
            {
                (await throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval))
                .Which.Should().Be(42);
            };

            // Assert
            await act.Should().NotThrowAsync();
        }
        public void When_no_exception_should_be_thrown_for_async_func_after_wait_time_but_it_was_it_should_throw()
        {
            // Arrange
            var waitTime     = 2.Seconds();
            var pollInterval = 10.Milliseconds();

            var clock = new FakeClock();
            var timer = clock.StartTimer();

            clock.Delay(waitTime);
            clock.CompletesBeforeTimeout();

            Func <Task> throwLongerThanWaitTime = async() =>
            {
                if (timer.Elapsed <= waitTime.Multiply(1.5))
                {
                    throw new ArgumentException("An exception was forced");
                }

                await Task.Delay(0);
            };

            // Act
            Func <Task> action = () => throwLongerThanWaitTime.Should(clock)
                                 .NotThrowAfterAsync(waitTime, pollInterval, "we passed valid arguments");

            // Assert
            action.Should().Throw <XunitException>()
            .WithMessage("Did not expect any exceptions after 2s because we passed valid arguments*");
        }