private static void AssertRetryProcessorReportsContinue(HistoryEvent[] history, int firstEventIndex, int maxNumberOfAttempts) { var shouldRetry = RetryProcessor.Process( history, history[firstEventIndex], maxNumberOfAttempts, onSuccess: result => { Assert.True(false, $"Unexpected output: {result}"); }, onFinalFailure: reason => { Assert.True(false, $"Unexpected failure: {reason}"); }); Assert.True(shouldRetry); }
public async Task ProcessFullFailure() { var processor = Substitute.For <IProcessor <int> >(); processor.Process(1).Returns(false); var rp = new RetryProcessor <int>(processor); var result = await rp.Process(1); Assert.IsFalse(result); processor.Received(3).Process(1); }
public async Task Process() { var processor = Substitute.For <IProcessor <int> >(); processor.Process(1).Returns(true); var rp = new RetryProcessor <int>(processor); var result = await rp.Process(1); Assert.IsTrue(result); processor.Received().Process(1); }
public async Task ProcessSingleFailure() { var processor = Substitute.For <IProcessor <int> >(); processor.Process(1).Returns(false, true); var rp = new RetryProcessor <int>(processor); var result = await rp.Process(1); Assert.IsTrue(result); await processor.Received(2).Process(1); }
private static void AssertRetryProcessorReportsSuccess(HistoryEvent[] history, int firstEventIndex, int maxNumberOfAttempts, string expectedOutput) { string actualOutput = null; var shouldRetry = RetryProcessor.Process( history, history[firstEventIndex], maxNumberOfAttempts, onSuccess: result => { Assert.Null(actualOutput); actualOutput = result; }, onFinalFailure: reason => { Assert.True(false, $"Unexpected failure: {reason}"); }); Assert.False(shouldRetry); Assert.Equal(expectedOutput, actualOutput); }