public void RunWithRetriesShouldThrowOnInvalidRetriesValue(int retries) { // action is never called if the value is zero or negative RetriesTestObject jt = new RetriesTestObject() { Treshold = 3 }; Action act = () => CoreExtensions.RunWithRetries(retries, jt.IncreaseCount); act.ShouldThrowExactly <ArgumentException>("Invalid value given for retries count."); }
public void TestRunWithRetriesAllRetries() { // treshold will not be reached so the method should be called as many times retries is defined RetriesTestObject jt = new RetriesTestObject() { Treshold = 100 }; int retries = 3; CoreExtensions.RunWithRetries(retries, jt.IncreaseCount); jt.Count.Should().Be(retries); }
public void TestRunWithRetriesExitEarly() { // treshold will be reached so the method should not be called as many times as defined by retries // method will return true as soon as count reaches treshold and the implementation stops retrying when true is returned int treshold = 3; RetriesTestObject jt = new RetriesTestObject() { Treshold = treshold }; CoreExtensions.RunWithRetries(5, jt.IncreaseCount); jt.Count.Should().Be(treshold); }