public async Task AsyncMaxAttemptsCorrectMethodTest(int inputValue, int expectedResult) { var beforeRetryCount = 0; var callStrategy = new MaxAttemptsRetriableAsyncCallStrategy(5, 1); var result = await callStrategy.CallAsync(() => CorrectActionAsync(inputValue), e => e is IOException, () => beforeRetryCount ++); Assert.That(beforeRetryCount, Is.EqualTo(0)); Assert.That(result, Is.EqualTo(expectedResult)); }
public void AsyncMaxAttemptsFitExceptionTest() { var beforeRetryCount = 0; var callActionCount = new CallCounter(); var callStrategy = new MaxAttemptsRetriableAsyncCallStrategy(5, 1); Assert.ThrowsAsync <AttemptsExceededException>(() => callStrategy.CallAsync(() => IOExceptionActionAsync(callActionCount), e => e is IOException, () => beforeRetryCount++)); Assert.That(beforeRetryCount, Is.EqualTo(4)); Assert.That(callActionCount.Count, Is.EqualTo(5)); }