Exemple #1
0
        public async Task WhenErrorTypeSetMultipleTimes_ExpectLastWins()
        {
            var builder = CreateBuilder().WithError(TestResource.Default1()).WithLink(MockUri);

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

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