public async Task Should_complete_within_finishes() { // arrange var asyncAssertions = new AsyncActionAssertions(() => Tester(false)); // act + assert await asyncAssertions.ShouldCompleteWithin(200.Milliseconds()); }
public async Task Expected_exception_happens() { // arrange var asyncAssertions = new AsyncActionAssertions(() => Tester(true)); // act + assert (no exception = pass) await asyncAssertions.ShouldThrow <ArgumentException>(); }
public async Task Should_complete_within_finishes_throws_exception() { // arrange var asyncAssertions = new AsyncActionAssertions(ThrowException); // act + assert await asyncAssertions.InvokingAsync(a => a.ShouldCompleteWithin(200.Milliseconds())) .ShouldThrow <ArgumentException>(); }
public async Task Should_complete_within_doesntfinish() { // arrange var asyncAssertions = new AsyncActionAssertions(() => Tester(false)); // act + assert await asyncAssertions.InvokingAsync(a => a.ShouldCompleteWithin(50.Milliseconds())) .ShouldThrow <AssertionException>(); }
public static async Task ShouldCompleteWithin(this Task task, TimeSpan time, string reason = "", params object[] reasonArgs) { var assertions = new AsyncActionAssertions(() => task); await assertions.ShouldCompleteWithin(time, reason, reasonArgs); }
public void Expected_exception_does_not_happen() { // arrange var asyncAssertions = new AsyncActionAssertions(() => Tester(false)); // act + assert asyncAssertions .Invoking(a => a.ShouldThrow <ArgumentException>().Wait()) .ShouldThrow <AggregateException>() .WithInnerException <AssertionException>() ; }