public void PollToCompletion_Timeout() { var pollSource = new PollSource(TimeSpan.FromSeconds(10), 5); var pollSettings = new PollSettings(Expiration.FromTimeout(TimeSpan.FromSeconds(5)), TimeSpan.FromSeconds(2)); pollSource.Scheduler.Run(() => { Assert.Throws<TimeoutException>(() => pollSource.PollRepeatedly(pollSettings)); // We give up at t=4 because the next call would be after the expiration. Assert.Equal(TimeSpan.FromSeconds(4), pollSource.RunningTime); }); }
public void PollToCompletion_Success() { var pollSource = new PollSource(TimeSpan.FromSeconds(3), 5); var pollSettings = new PollSettings(Expiration.FromTimeout(TimeSpan.FromSeconds(5)), TimeSpan.FromSeconds(2)); pollSource.Scheduler.Run(() => { var result = pollSource.PollRepeatedly(pollSettings); Assert.Equal(5, result); Assert.Equal(TimeSpan.FromSeconds(4), pollSource.RunningTime); }); }
public void PollToCompletion_Timeout() { var pollSource = new PollSource(TimeSpan.FromSeconds(10), 5); var pollSettings = new PollSettings(Expiration.FromTimeout(TimeSpan.FromSeconds(5)), TimeSpan.FromSeconds(2)); pollSource.Scheduler.Run(() => { Assert.Throws <TimeoutException>(() => pollSource.PollRepeatedly(pollSettings, CancellationToken.None)); // We give up at t=4 because the next call would be after the expiration. Assert.Equal(TimeSpan.FromSeconds(4), pollSource.RunningTime); }); }
public void PollToCompletionExponential_Success() { var pollSource = new PollSource(TimeSpan.FromSeconds(7), 5); var pollSettings = new PollSettings(Expiration.FromTimeout(TimeSpan.FromSeconds(20)), TimeSpan.FromSeconds(1), 2.0, TimeSpan.FromSeconds(3)); pollSource.Scheduler.Run(() => { var result = pollSource.PollRepeatedly(pollSettings, CancellationToken.None); Assert.Equal(5, result); Assert.Equal(TimeSpan.FromSeconds(9), pollSource.RunningTime); }); }