public async Task When_async_method_throws_exception_and_expected_not_to_throw_async_another_one_it_should_succeed() { // Arrange var asyncObject = new AsyncClass(); // Act Func <Task> action = () => asyncObject.ThrowAsync <ArgumentException>(); // Assert await action.Should().NotThrowAsync <InvalidOperationException>(); }
public async Task When_subject_throws_on_UI_thread_expected_async_exact_exception_it_should_succeed() { // Arrange var asyncObject = new AsyncClass(); // Act Func <Task> action = () => asyncObject.ThrowAsync <ArgumentException>(); // Assert await action.Should().ThrowExactlyAsync <ArgumentException>("because {0} should do that", "IFoo.Do"); }
public async Task When_async_method_throws_async_expected_exception_it_should_succeed() { // Arrange var asyncObject = new AsyncClass(); // Act Func <Task> action = () => asyncObject.ThrowAsync <ArgumentException>(); // Assert await action.Should().ThrowAsync <ArgumentException>(); }
public async Task When_subject_throws_subclass_of_expected_async_exact_exception_it_should_throw() { // Arrange var asyncObject = new AsyncClass(); // Act Func <Task> action = () => asyncObject.ThrowAsync <ArgumentNullException>(); Func <Task> testAction = () => action.Should().ThrowExactlyAsync <ArgumentException>("ABCDE"); // Assert await testAction.Should().ThrowAsync <XunitException>() .WithMessage("*ArgumentException*ABCDE*ArgumentNullException*"); }
public async void When_async_method_throws_async_expected_exception_it_should_succeed() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var asyncObject = new AsyncClass(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Func <Task> action = async() => await asyncObject.ThrowAsync <ArgumentException>(); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- await action.Should().ThrowAsync <ArgumentException>(); }
public async Task When_subject_throws_subclass_of_expected_async_exception_it_should_succeed() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var asyncObject = new AsyncClass(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Func <Task> action = async() => await asyncObject.ThrowAsync <ArgumentNullException>(); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- await action.Should().ThrowAsync <ArgumentException>("because {0} should do that", "IFoo.Do"); }