private static void RunBasicTests(RetryStrategy strategy, int expectedTimeMs) { DateTime start = DateTime.UtcNow; var retry = new RetryPoliciy <AllAreTransient>(strategy); int tries = 0; Assert.Throws <MockException>( () => retry.Execute( attempt => { ++tries; throw new MockException("Deliberately fail"); }) ); DateTime finish = DateTime.UtcNow; TimeSpan time = finish.Subtract(start); Assert.AreEqual(ATTEMPTS, tries); // We expect that it could take longer than expected, but never LESS. Assert.GreaterOrEqual(expectedTimeMs, time.TotalMilliseconds, "Delay was too short."); }
private static void RunBasicTests(RetryStrategy strategy, int expectedTimeMs) { DateTime start = DateTime.UtcNow; var retry = new RetryPoliciy<AllAreTransient>(strategy); int tries = 0; Assert.Throws<MockException>( () => retry.Execute( attempt => { ++tries; throw new MockException("Deliberately fail"); }) ); DateTime finish = DateTime.UtcNow; TimeSpan time = finish.Subtract(start); Assert.AreEqual(ATTEMPTS, tries); // We expect that it could take longer than expected, but never LESS. Assert.GreaterOrEqual(expectedTimeMs, time.TotalMilliseconds, "Delay was too short."); }