public async Task When_async_method_does_not_throw_async_exception_on_UI_thread_and_that_was_expected_it_should_succeed() { // Arrange var asyncObject = new AsyncClass(); // Act Func <Task> action = () => asyncObject.SucceedAsync(); // Assert await action.Should().NotThrowAsync(); }
public async Task When_async_method_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed() { // Arrange var asyncObject = new AsyncClass(); // Act Func <Task> action = () => asyncObject .Awaiting(_ => asyncObject.SucceedAsync()) .Should().NotThrowAsync <InvalidOperationException>(); // Assert await action.Should().NotThrowAsync(); }
public async Task When_poll_interval_is_zero_for_async_func_executed_with_wait_it_should_not_throw() { // Arrange var waitTime = 10.Milliseconds(); var pollInterval = 0.Milliseconds(); var clock = new FakeClock(); var asyncObject = new AsyncClass(); Func <Task> someFunc = () => asyncObject.SucceedAsync(); // Act Func <Task> act = () => someFunc.Should(clock).NotThrowAfterAsync(waitTime, pollInterval); // Assert await act.Should().NotThrowAsync(); }
public async Task When_poll_interval_is_negative_for_async_func_it_should_throw() { // Arrange var waitTime = 10.Milliseconds(); var pollInterval = -1.Milliseconds(); var asyncObject = new AsyncClass(); Func <Task> someFunc = () => asyncObject.SucceedAsync(); // Act Func <Task> act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval); // Assert await act.Should().ThrowAsync <ArgumentOutOfRangeException>() .WithMessage("* value of pollInterval must be non-negative*"); }
public void When_wait_time_is_negative_for_async_func_executed_with_wait_it_should_throw() { // Arrange var waitTime = -1.Milliseconds(); var pollInterval = 10.Milliseconds(); var asyncObject = new AsyncClass(); Func <Task> someFunc = () => asyncObject.SucceedAsync(); // Act Action act = () => someFunc.Should().NotThrowAfter(waitTime, pollInterval); // Assert act.Should().Throw <ArgumentOutOfRangeException>() .WithMessage("* value of waitTime must be non-negative*"); }
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(); }