コード例 #1
0
        public async Task WhenDefaultResultAndResultTypesMismatch_ExpectException()
        {
            var builder = new MockTypedBuilderFactory().Create().WithError(TestResult.Default1()).WithUri(MockUri);

            //act
            await Should.ThrowAsync <TypeMismatchException>(
                builder.WithDefaultResult(TestResult.Default1())
                .Advanced.WithExceptionFactory(context => null)
                .ResultAsync <Uri>()
                );
        }
コード例 #2
0
        public async Task WhenDefaultResultAndResultTypesMismatchAndSuppressTypeException_ExpectNullResult()
        {
            var builder = new MockTypedBuilderFactory().Create().WithError(TestResult.Default1()).WithUri(MockUri);

            //act
            var actual = await builder.WithDefaultResult(TestResult.Default1())
                         .Advanced
                         .WithSuppressTypeMismatchExceptions()
                         .OnException(ctx => ctx.ExceptionHandled = true)
                         .ResultAsync <Uri>();

            actual.ShouldBeNull();
        }