public async Task Retry_RetryUntilFailure() { FaultyClass faultyClass = new FaultyClass() { ExceptionToThrow = new ArgumentNullException(), TriesUntilSuccess = 12 }; var result = await Retry.Run( task : () => faultyClass.FaultyTask(), retryExceptionHandler : (ex, ct) => faultyClass.ExceptionHandler(ex, ct)); }
public async Task Retry_NoRetryWhenTaskSucceeds() { FaultyClass faultyClass = new FaultyClass() { ExceptionToThrow = null }; var result = await Retry.Run( task : () => faultyClass.FaultyTask(), retryExceptionHandler : (ex, ct) => faultyClass.ExceptionHandler(ex, ct)); Assert.IsNull(faultyClass.ExceptionReceived); Assert.AreEqual(1, faultyClass.CallCount); }
public async Task Retry_RetryThenSucceed() { FaultyClass faultyClass = new FaultyClass() { ExceptionToThrow = new ArgumentNullException(), TriesUntilSuccess = 3 }; var result = await Retry.Run( task : () => faultyClass.FaultyTask(), retryExceptionHandler : (ex, ct) => faultyClass.ExceptionHandler(ex, ct)); Assert.IsNotNull(faultyClass.ExceptionReceived); Assert.AreEqual(3, faultyClass.CallCount); }