예제 #1
0
        public void and_on_inner_exception_by_type_and_condition_2()
        {
            var settings = new DaemonSettings();

            settings.OnException <InvalidOperationException>()
            .AndInner(x => (x is CustomException {
                ErrorCode: 500
            }));
        public void determine_continuation_for_skip_falls_back_to_stop_if_not_apply_event_exception()
        {
            var settings = new DaemonSettings();

            settings.OnException <BadImageFormatException>().SkipEvent();

            settings.DetermineContinuation(new BadImageFormatException(), 0)
            .ShouldBeOfType <StopShard>();
        }
        public void unknown_exception_type_just_gets_a_stop()
        {
            var settings = new DaemonSettings();

            settings.OnException <BadImageFormatException>()
            .RetryLater(1.Seconds(), 2.Seconds(), 3.Seconds());

            settings.DetermineContinuation(new DivideByZeroException(), 0)
            .ShouldBeOfType <StopShard>();
        }
예제 #4
0
        public void filter_by_exception_type()
        {
            var settings = new DaemonSettings();

            settings.OnException <NpgsqlException>();

            var policy = settings.Policies.Single();

            policy.Matches(new NpgsqlException()).ShouldBeTrue();
            policy.Matches(new DivideByZeroException()).ShouldBeFalse();
        }
예제 #5
0
        public void filter_by_exception_type_and_more()
        {
            var settings = new DaemonSettings();

            settings.OnException <CustomException>(x => x.ErrorCode == 200);

            var policy = settings.Policies.Single();

            policy.Matches(new NpgsqlException()).ShouldBeFalse();
            policy.Matches(new CustomException(200)).ShouldBeTrue();
            policy.Matches(new CustomException(201)).ShouldBeFalse();
        }
예제 #6
0
        public void and_on_inner_exception_by_type()
        {
            var settings = new DaemonSettings();

            settings.OnException <InvalidOperationException>()
            .AndInner <CustomException>();

            var policy = settings.Policies.Single();

            policy.Matches(new InvalidCastException()).ShouldBeFalse();
            policy.Matches(new InvalidOperationException()).ShouldBeFalse();
            policy.Matches(new InvalidOperationException("boom.", new DivideByZeroException())).ShouldBeFalse();
            policy.Matches(new InvalidOperationException("boom.", new CustomException(111))).ShouldBeTrue();
        }
        public void retry_logic_with_no_additional_continuation()
        {
            var settings = new DaemonSettings();

            settings.OnException <BadImageFormatException>()
            .RetryLater(1.Seconds(), 2.Seconds(), 3.Seconds());

            settings.DetermineContinuation(new BadImageFormatException(), 0)
            .ShouldBe(new RetryLater(1.Seconds()));

            settings.DetermineContinuation(new BadImageFormatException(), 1)
            .ShouldBe(new RetryLater(2.Seconds()));

            settings.DetermineContinuation(new BadImageFormatException(), 2)
            .ShouldBe(new RetryLater(3.Seconds()));

            settings.DetermineContinuation(new BadImageFormatException(), 3)
            .ShouldBeOfType <StopShard>();
        }
        public void retry_logic_then_pause()
        {
            var settings = new DaemonSettings();

            settings.OnException <BadImageFormatException>()
            .RetryLater(1.Seconds(), 2.Seconds(), 3.Seconds())
            .Then.Pause(5.Seconds());

            settings.DetermineContinuation(new BadImageFormatException(), 0)
            .ShouldBe(new RetryLater(1.Seconds()));

            settings.DetermineContinuation(new BadImageFormatException(), 1)
            .ShouldBe(new RetryLater(2.Seconds()));

            settings.DetermineContinuation(new BadImageFormatException(), 2)
            .ShouldBe(new RetryLater(3.Seconds()));

            settings.DetermineContinuation(new BadImageFormatException(), 3)
            .ShouldBe(new PauseShard(5.Seconds()));
        }