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()); }
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(); }
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); }
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(); }
public void Retried_operations_are_logged(Exception error, FakeWorkflowLogger log) { var sut = new RetryBehavior(2, TimeSpan.Zero).AttachTo(new FakeOperation { ThrowOnExecute = error, ErrorCount = 2 }); sut.Initialize(new FakeWorkflowConfiguration { Logger = log }); sut.Execute(); Assert.Equal(2, log.AppliedBehaviors.Count); Assert.Equal("Operation retried", log.AppliedBehaviors[0].Description); }
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()); }
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(); }