public async Task WhenErrorAndErrorHandlerTypesMismatch_ExpectException()
        {
            var builder = new MockTypedBuilderFactory().Create().WithError(TestResult.Default1()).WithUri(MockUri);

            //act
            await Should.ThrowAsync <TypeMismatchException>(
                builder.WithErrorType <TestResult>().Advanced.OnError <Uri>(ctx => { var error = ctx.Error; }).ResultAsync <TestResult>());
        }
        public async Task WhenErrorAndErrorHandlerTypesMismatchAndSuppressTypeException_ExpectResult()
        {
            var builder = new MockTypedBuilderFactory().Create().WithError(TestResult.Default1()).WithUri(MockUri);

            //act
            var actual = await builder
                         .WithErrorType <TestResult>()
                         .Advanced
                         .WithSuppressTypeMismatchExceptions()
                         .OnError <Uri>(ctx =>
            {
                ctx.ErrorHandled = true;
            })
                         .ResultAsync <TestResult>();

            actual.ShouldBeNull();
        }
        public async Task WhenErrorHandlerIsObjectType_ExpectSuccess()
        {
            var builder = new MockTypedBuilderFactory().Create().WithError(TestResult.Default1()).WithUri(MockUri);

            //act
            var called = false;
            var result = await builder
                         .WithErrorType <TestResult>()
                         .Advanced
                         .OnError <object>(ctx =>
            {
                ctx.ErrorHandled = true;
                called           = true;
            })
                         .ResultAsync <SubTestResult>();

            result.ShouldBeNull();
            called.ShouldBeTrue();
        }
        public async Task WhenErrorTypeSetMultipleTimes_ExpectLastWins()
        {
            var builder = new MockTypedBuilderFactory().Create().WithError(TestResult.Default1()).WithUri(MockUri);

            //act
            Type       type   = null;
            TestResult error  = null;
            var        result = await builder
                                .WithErrorType <Uri>()
                                .WithErrorType <string>()
                                .WithErrorType <TestResult>()
                                .Advanced
                                .OnError <object>(ctx =>
            {
                ctx.ErrorHandled = true;
                type             = ctx.ErrorType;
                error            = ctx.Error as TestResult;
            })
                                .ResultAsync <TestResult>();

            error.ShouldNotBeNull();
            result.ShouldBeNull();
            typeof(TestResult).ShouldBe(type);
        }