public async Task When_subject_throws_the_expected_exact_exception_through_ValueTask_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act / Assert
            await asyncObject
            .Awaiting(x => x.ThrowAsyncValueTask <ArgumentNullException>())
            .Should().ThrowExactlyAsync <ArgumentNullException>();
        }
        public async Task When_ValueTask_async_method_of_T_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(_ => asyncObject.ReturnValueTaskInt())
                                 .Should().NotThrowAsync <InvalidOperationException>();

            // Assert
            await action.Should().NotThrowAsync();
        }
        public async Task When_async_method_throws_exception_through_ValueTask_and_expected_not_to_throw_another_one_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.ThrowAsyncValueTask <ArgumentException>())
                                 .Should().NotThrowAsync <InvalidOperationException>();

            // Assert
            await action.Should().NotThrowAsync();
        }
        public void When_async_method_does_not_throw_exception_and_that_was_expected_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Action action = () => asyncObject
                            .Awaiting(x => x.SucceedAsync())
                            .Should().NotThrow();

            // Assert
            action.Should().NotThrow();
        }
        public async Task When_async_method_throws_expected_exception_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.ThrowAsync <ArgumentException>())
                                 .Should().ThrowAsync <ArgumentException>();

            // Assert
            await action.Should().NotThrowAsync();
        }
        public void When_async_method_of_T_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Action action = () => asyncObject
                            .Awaiting(x => asyncObject.ReturnTaskInt())
                            .Should().NotThrow <InvalidOperationException>();

            // Assert
            action.Should().NotThrow();
        }
        public void When_async_method_throws_exception_and_expected_not_to_throw_another_one_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Action action = () => asyncObject
                            .Awaiting(x => x.ThrowAsync <ArgumentException>())
                            .Should().NotThrow <InvalidOperationException>();

            // Assert
            action.Should().NotThrow();
        }
        public async Task When_async_method_does_not_throw_exception_through_ValueTask_and_that_was_expected_it_should_succeed()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.SucceedAsyncValueTask())
                                 .Should().NotThrowAsync();

            // Assert
            await action.Should().NotThrowAsync();
        }
        public async Task When_async_method_throws_exception_through_ValueTask_and_no_exception_was_expected_it_should_fail()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.ThrowAsyncValueTask <ArgumentException>())
                                 .Should().NotThrowAsync();

            // Assert
            await action.Should().ThrowAsync <XunitException>()
            .WithMessage("Did not expect any exception, but found System.ArgumentException*");
        }
        public async Task When_async_method_throws_unexpected_exception_through_ValueTask_it_should_fail()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.ThrowAsyncValueTask <ArgumentException>())
                                 .Should().ThrowAsync <InvalidOperationException>("because {0} should do that", "IFoo.Do");

            // Assert
            await action.Should().ThrowAsync <XunitException>()
            .WithMessage("Expected a <System.InvalidOperationException> to be thrown because IFoo.Do should do that, but found <System.ArgumentException>*");
        }
        public async Task When_async_method_does_not_throw_expected_exception_it_should_fail()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.SucceedAsync())
                                 .Should().ThrowAsync <InvalidOperationException>("because {0} should do that", "IFoo.Do");

            // Assert
            await action.Should().ThrowAsync <XunitException>()
            .WithMessage("Expected a <System.InvalidOperationException> to be thrown because IFoo.Do should do that, but no exception was thrown.");
        }
        public async Task When_subject_throws_aggregate_exception_and_not_expected_exact_exception_through_ValueTask_it_should_fail()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.ThrowAggregateExceptionAsyncValueTask <ArgumentException>())
                                 .Should().ThrowExactlyAsync <ArgumentException>("because {0} should do that", "IFoo.Do");

            // Assert
            await action.Should().ThrowAsync <XunitException>()
            .WithMessage("Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.AggregateException.");
        }
        public void When_async_method_throws_exception_expected_not_to_be_thrown_it_should_fail()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Action action = () => asyncObject
                            .Awaiting(x => x.ThrowAsync <ArgumentException>())
                            .Should().NotThrow <ArgumentException>();

            // Assert
            action.Should().Throw <XunitException>()
            .WithMessage("Did not expect System.ArgumentException, but found*");
        }
        public async Task When_ValueTask_async_method_of_T_throws_exception_expected_not_to_be_thrown_it_should_fail()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Func <Task> action = () => asyncObject
                                 .Awaiting(x => x.ThrowValueTaskIntAsync <ArgumentException>(true))
                                 .Should().NotThrowAsync <ArgumentException>();

            // Assert
            await action.Should().ThrowAsync <XunitException>()
            .WithMessage("Did not expect System.ArgumentException, but found System.ArgumentException*");
        }
        public void When_subject_throws_subclass_of_expected_exact_exception_it_should_fail()
        {
            // Arrange
            var asyncObject = new AsyncClass();

            // Act
            Action action = () => asyncObject
                            .Awaiting(x => x.ThrowAsync <ArgumentNullException>())
                            .Should().ThrowExactly <ArgumentException>("because {0} should do that", "IFoo.Do");

            // Assert
            action.Should().Throw <XunitException>()
            .WithMessage("Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.ArgumentNullException.");
        }
        public void When_subject_throws_the_expected_exact_exception_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var asyncObject = new AsyncClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act / Assert
            //-----------------------------------------------------------------------------------------------------------
            asyncObject
            .Awaiting(x => x.ThrowAsync <ArgumentNullException>())
            .Should().ThrowExactly <ArgumentNullException>();
        }
        public void When_async_method_throws_expected_exception_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var asyncObject = new AsyncClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => asyncObject
                            .Awaiting(x => x.ThrowAsync <ArgumentException>())
                            .Should().Throw <ArgumentException>();

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.Should().NotThrow();
        }
        public void When_async_method_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var asyncObject = new AsyncClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => asyncObject
                            .Awaiting(x => asyncObject.SucceedAsync())
                            .Should().NotThrow <InvalidOperationException>();

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.Should().NotThrow();
        }
        public void When_async_method_does_not_throw_expected_exception_it_should_fail()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var asyncObject = new AsyncClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => asyncObject
                            .Awaiting(x => x.SucceedAsync())
                            .Should().Throw <InvalidOperationException>("because {0} should do that", "IFoo.Do");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.Should().Throw <XunitException>()
            .WithMessage("Expected System.InvalidOperationException because IFoo.Do should do that, but no exception was thrown*");
        }
        public void When_async_method_throws_exception_and_no_exception_was_expected_it_should_fail()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var asyncObject = new AsyncClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => asyncObject
                            .Awaiting(x => x.ThrowAsync <ArgumentException>())
                            .Should().NotThrow();

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.Should().Throw <XunitException>()
            .WithMessage("Did not expect any exception, but found a System.ArgumentException*");
        }