public void DoWorkWillRetryForRetryExceptions() { var work = new WorkQueueItem(() => { throw new ArgumentException(); }, 2, new[] { typeof(ArgumentException) }); var result = work.DoWork(); Assert.That(result.Success, Is.False); Assert.That(result.ShouldRetry, Is.True); }
public void DoWorkDoesTheWork() { var actionCompleted = false; var work = new WorkQueueItem(() => actionCompleted = true, 1); var result = work.DoWork(); Assert.That(actionCompleted, Is.True); Assert.That(result.Success, Is.True); Assert.That(result.ShouldRetry, Is.False); }
public void DoWorkCatchesExceptions() { var exception = new Exception(); var work = new WorkQueueItem(() => { throw exception; }, 1); var result = work.DoWork(); Assert.That(result.Success, Is.False); Assert.That(result.ShouldRetry, Is.False); Assert.That(result.Exception, Is.EqualTo(exception)); }
public void ResultCanBeCalledMultipleTimes() { var work = new WorkQueueItem(() => { }, 1); work.DoWork(); var result1 = work.Result; var result2 = work.Result; Assert.That(result1, Is.EqualTo(result2)); }
public void TriesAreDecremented() { var work = new WorkQueueItem(() => { throw new ArgumentException(); }, 3, new[] { typeof(ArgumentException) }); var result = work.DoWork(); Assert.That(result.Success, Is.False); Assert.That(result.ShouldRetry, Is.True); Assert.That(result.Tries, Is.EqualTo(2)); result = work.DoWork(); Assert.That(result.Success, Is.False); Assert.That(result.ShouldRetry, Is.True); Assert.That(result.Tries, Is.EqualTo(1)); result = work.DoWork(); Assert.That(result.Success, Is.False); Assert.That(result.ShouldRetry, Is.False); Assert.That(result.Tries, Is.EqualTo(0)); }
public void ResultIsSetToTheLastResult() { var called = false; var work = new WorkQueueItem(() => { throw new ArgumentException(); }, 2, new[] {typeof (ArgumentException)}); var result = work.DoWork(); Assert.That(result.Success, Is.False); Assert.That(result.ShouldRetry, Is.True); result = work.DoWork(); Assert.That(result.Success, Is.False); Assert.That(result.ShouldRetry, Is.False); Assert.That(work.Result, Is.EqualTo(result)); }