public void When_asserting_async_void_method_should_not_throw_specific_exception_it_should_fail() { // Arrange var asyncObject = new AsyncClass(); Action asyncVoidMethod = async() => await asyncObject.IncompleteTask(); // Act Action action = () => asyncVoidMethod.Should().NotThrow <ArgumentException>(); // Assert action.Should().Throw <InvalidOperationException>("*async*void*"); }
public void When_asserting_async_void_method_should_throw_exactly_it_should_fail() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var asyncObject = new AsyncClass(); Action asyncVoidMethod = async() => await asyncObject.IncompleteTask(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action action = () => asyncVoidMethod.Should().ThrowExactly <ArgumentException>(); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- action.Should().Throw <InvalidOperationException>("*async*void*"); }