public void SecondRetryHitsSecondStage() { var backoff = new BackOffRetry(); var stopwatch = new Stopwatch(); stopwatch.Start(); backoff.BlockingRetry(); backoff.BlockingRetry(); var timeTaken = stopwatch.ElapsedMilliseconds; Assert.InRange(timeTaken, 800, 1200); }
public void StaysAtMaxStageAfterRepeatedRetries() { var backoff = new BackOffRetry(); backoff.BackOffStages = new List <int> { 300, 300, 300, 1000 }; var stopwatch = new Stopwatch(); stopwatch.Start(); backoff.BlockingRetry(); backoff.BlockingRetry(); backoff.BlockingRetry(); backoff.BlockingRetry(); backoff.BlockingRetry(); var timeTaken = stopwatch.ElapsedMilliseconds; Assert.InRange(timeTaken, 2200, 3000); }
public void ResetsStageAfterDelay() { var backoff = new BackOffRetry(); backoff.BackOffStages = new List <int> { 0, 500, 1000, 2000 }; backoff.BlockingRetry(); backoff.BlockingRetry(); Thread.Sleep(3000); var stopwatch = new Stopwatch(); stopwatch.Start(); backoff.BlockingRetry(); var timeTaken = stopwatch.ElapsedMilliseconds; Assert.InRange(timeTaken, 0, 100); }