示例#1
0
 public async Task PollToCompletionAsync_Timeout()
 {
     var pollSource = new PollSource(TimeSpan.FromSeconds(10), 5);
     var pollSettings = new PollSettings(Expiration.FromTimeout(TimeSpan.FromSeconds(5)), TimeSpan.FromSeconds(2));
     await pollSource.Scheduler.RunAsync(async () =>
     {
         await Assert.ThrowsAsync<TimeoutException>(() => pollSource.PollRepeatedlyAsync(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 async Task PollToCompletionAsync_Success()
 {
     var pollSource = new PollSource(TimeSpan.FromSeconds(3), 5);
     var pollSettings = new PollSettings(Expiration.FromTimeout(TimeSpan.FromSeconds(5)), TimeSpan.FromSeconds(2));
     await pollSource.Scheduler.RunAsync(async () =>
     {
         var result = await pollSource.PollRepeatedlyAsync(pollSettings);
         Assert.Equal(5, result);
         Assert.Equal(TimeSpan.FromSeconds(4), pollSource.RunningTime);
     });
 }
示例#3
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);
     });
 }
示例#4
0
 public async Task PollToCompletionAsync_Timeout()
 {
     var pollSource   = new PollSource(TimeSpan.FromSeconds(10), 5);
     var pollSettings = new PollSettings(Expiration.FromTimeout(TimeSpan.FromSeconds(5)), TimeSpan.FromSeconds(2));
     await pollSource.Scheduler.RunAsync(async() =>
     {
         await Assert.ThrowsAsync <TimeoutException>(() => pollSource.PollRepeatedlyAsync(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);
     });
 }
示例#5
0
 public async Task PollToCompletionExponentialAsync_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));
     await pollSource.Scheduler.RunAsync(async() =>
     {
         var result = await pollSource.PollRepeatedlyAsync(pollSettings, CancellationToken.None);
         Assert.Equal(5, result);
         Assert.Equal(TimeSpan.FromSeconds(9), pollSource.RunningTime);
     });
 }
示例#6
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, CancellationToken.None);
                Assert.Equal(5, result);
                Assert.Equal(TimeSpan.FromSeconds(4), pollSource.RunningTime);
            });
        }