Ejemplo n.º 1
0
        public async Task Should_complete_within_finishes()
        {
            // arrange
            var asyncAssertions = new AsyncActionAssertions(() => Tester(false));

            // act + assert
            await asyncAssertions.ShouldCompleteWithin(200.Milliseconds());
        }
Ejemplo n.º 2
0
        public async Task Expected_exception_happens()
        {
            // arrange
            var asyncAssertions = new AsyncActionAssertions(() => Tester(true));

            // act + assert (no exception = pass)
            await asyncAssertions.ShouldThrow <ArgumentException>();
        }
Ejemplo n.º 3
0
        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>();
        }
Ejemplo n.º 4
0
        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>();
        }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
        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>()
            ;
        }