public WorkQueueItemResult DoWork() { WorkQueueItemResult result; try { _work(); result = new WorkQueueItemResult(true, _tries); } catch (Exception exception) { var exceptionType = exception.GetType(); _tries--; if (_retryExceptions.Any(x => x.IsAssignableFrom(exceptionType))) { result = new WorkQueueItemResult(false, _tries, exception); } else { result = new WorkQueueItemResult(false, 0, exception); } } if (!result.ShouldRetry) { _result = result; _event.Set(); } return result; }
public WorkQueueItemResult DoWork() { WorkQueueItemResult result; try { _work(); result = new WorkQueueItemResult(true, _tries); } catch (Exception exception) { var exceptionType = exception.GetType(); _tries--; if (_retryExceptions.Any(x => x.IsAssignableFrom(exceptionType))) { result = new WorkQueueItemResult(false, _tries, exception); } else { result = new WorkQueueItemResult(false, 0, exception); } } if (!result.ShouldRetry) { _result = result; _event.Set(); } return(result); }
public void ItSavesTheException() { var exception = new Exception(); var result = new WorkQueueItemResult(false, 0, exception); Assert.That(result.Exception, Is.EqualTo(exception)); }
public void ShouldRetryReturnsTheCorrectValue(bool success, uint tries, bool expected) { var result = new WorkQueueItemResult(success, tries); Assert.That(result.ShouldRetry, Is.EqualTo(expected)); }
public void ItSavesTries(uint tries) { var result = new WorkQueueItemResult(true, tries); Assert.That(result.Tries, Is.EqualTo(tries)); }
public void ItSavesSuccess(bool success) { var result = new WorkQueueItemResult(success, 0); Assert.That(result.Success, Is.EqualTo(success)); }