public async Task FailsOnce() { await Endeavor.Go <PlayItAgainException>(async() => await Go(timesFailed == 0), e => CountFails(), 3, 50); timesFailed.Should().Be(1); }
public async Task FailsAFewTimes() { await Endeavor.Go <PlayItAgainException>(async() => await Go(timesFailed <= 3), async e => await CountFails(), 5, 50); timesFailed.Should().Be(4); }
public async Task AlwaysFails() { try { await Endeavor.Go <PlayItAgainException>(async() => await Bork(), async e => await CountFails(), 3, 50); throw new Exception($"didn't catch an {nameof(PlayItAgainException)}"); } catch (PlayItAgainException ex) { ex.Should().NotBeNull(); } timesFailed.Should().Be(3); }
public void Success() { Endeavor.Go <PlayItAgainException>(() => Go(), e => throw new Exception("should not be here")); timesFailed.Should().Be(0); }