public void MaxAttemptsCorrectMethodTest(int inputValue, int expectedResult) { var beforeRetryCount = 0; var callStrategy = new MaxAttemptsRetriableCallStrategy(5, 1); var result = callStrategy.Call(() => CorrectAction(inputValue), e => e is IOException, () => beforeRetryCount++); Assert.That(beforeRetryCount, Is.EqualTo(0)); Assert.That(result, Is.EqualTo(expectedResult)); }
public void MaxAttemptsNotFitExceptionTest() { var beforeRetryCount = 0; var callActionCount = new CallCounter(); var callStrategy = new MaxAttemptsRetriableCallStrategy(5, 1); Assert.Throws <IOException>(() => callStrategy.Call(() => IOExceptionAction(callActionCount), e => e is StackOverflowException, () => beforeRetryCount++)); Assert.That(beforeRetryCount, Is.EqualTo(0)); Assert.That(callActionCount.Count, Is.EqualTo(1)); }
public void MaxAttemptsFitExceptionTest() { var beforeRetryCount = 0; var callActionCount = new CallCounter(); var callStrategy = new MaxAttemptsRetriableCallStrategy(5, 1); Assert.Throws <AttemptsExceededException>(() => callStrategy.Call(() => IOExceptionAction(callActionCount), e => e is IOException, () => beforeRetryCount++)); Assert.That(beforeRetryCount, Is.EqualTo(4)); Assert.That(callActionCount.Count, Is.EqualTo(5)); }