public async Task Expected_exception_happens() { // arrange var asyncAssertions = new AsyncActionAssertionsWithResult <int>(() => Tester(true)); // act + assert (no exception = pass) await asyncAssertions.ShouldThrow <ArgumentException>(); }
public async Task Should_complete_within_finishes_throws_exception() { // arrange var asyncAssertions = new AsyncActionAssertionsWithResult <int>(() => Tester(true)); // act + assert await asyncAssertions.InvokingAsync(a => a.ShouldCompleteWithin(200.Milliseconds())) .ShouldThrow <ArgumentException>(); }
public async Task Should_complete_within_doesntfinish() { // arrange var asyncAssertions = new AsyncActionAssertionsWithResult <int>(() => Tester(false)); // act + assert await asyncAssertions.InvokingAsync(a => a.ShouldCompleteWithin(50.Milliseconds())) .ShouldThrow <AssertionException>(); }
public void Expected_exception_does_not_happen() { // arrange var asyncAssertions = new AsyncActionAssertionsWithResult <int>(() => Tester(false)); // act + assert asyncAssertions .Invoking(a => a.ShouldThrow <ArgumentException>().Wait()) .ShouldThrow <AggregateException>() .WithInnerException <AssertionException>() ; }
public async Task Should_complete_within_finishes() { // arrange var asyncAssertions = new AsyncActionAssertionsWithResult <int>(() => Tester(false)); // act var result = await asyncAssertions.ShouldCompleteWithin(200.Milliseconds()); // assert result .Should() .Be(5); }