Esempio n. 1
0
        public void Failing_operations_are_retried_aspoecific_number_of_times()
        {
            var operation = new FakeOperation { ThrowOnExecute = new Exception(), ErrorCount = 2 };
            var sut = new RetryBehavior(1, TimeSpan.Zero);
            sut.AttachTo(operation);

            Assert.Throws<Exception>(() => sut.Execute());
        }
Esempio n. 2
0
        public void Failing_operations_are_retried()
        {
            var operation = new FakeOperation { ThrowOnExecute = new Exception(), ErrorCount = 1 };
            var sut = new RetryBehavior(1, TimeSpan.Zero);
            sut.AttachTo(operation);

            sut.Execute();
        }
Esempio n. 3
0
        public void Retries_are_delayed_the_specified_duration()
        {
            var operation = new FakeOperation { ThrowOnExecute = new Exception(), ErrorCount = 1 };
            var sut = new RetryBehavior(1, TimeSpan.FromSeconds(5));
            sut.AttachTo(operation);
            var before = Time.OffsetUtcNow;

            sut.Execute();

            var duration = Time.OffsetUtcNow - before;
            Assert.Equal(TimeSpan.FromSeconds(5), duration); 
        }
Esempio n. 4
0
        public void You_can_retry_an_operation_where_an_indempotent_child_operation_has_executed()
        {
            var operation = new FakeOperation(new IndempotentOperation { ThrowOnExecute = new Exception(), ErrorCount = 1 });
            var sut = new RetryBehavior(1, TimeSpan.Zero);
            sut.AttachTo(operation);

            sut.Execute();
        }
Esempio n. 5
0
        public void When_retry_exception_types_are_specified_errors_of_different_types_will_not_be_retried()
        {
            var operation = new FakeOperation { ThrowOnExecute = new NullReferenceException(), ErrorCount = 1 };
            var sut = new RetryBehavior(1, TimeSpan.Zero, typeof(InsufficientMemoryException));
            sut.AttachTo(operation);

            Assert.Throws<NullReferenceException>(() => sut.Execute());
        }
Esempio n. 6
0
        public void When_retry_exception_types_are_specified_errors_of_sub_types_will_be_retried()
        {
            var operation = new FakeOperation { ThrowOnExecute = new ArgumentNullException(), ErrorCount = 1 };
            var sut = new RetryBehavior(1, TimeSpan.Zero, typeof(ArgumentException));
            sut.AttachTo(operation);

            sut.Execute();
        }