예제 #1
0
 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);
     });
 }
예제 #2
0
 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);
     });
 }
예제 #3
0
        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);
            });
        }
예제 #4
0
        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);
            });
        }