public void Create_Default_1000_2000_Reset_1000_Wait() { var times = new List<TimeSpan> { TimeSpan.FromMilliseconds(1000), TimeSpan.FromMilliseconds(2000), TimeSpan.FromMilliseconds(3000) }; var test = new QueueWait(times, GetCancel()); var watch = new Stopwatch(); watch.Start(); test.Wait(); watch.Stop(); Assert.InRange(watch.ElapsedMilliseconds, 950, 2000); watch.Restart(); test.Wait(); watch.Stop(); Assert.InRange(watch.ElapsedMilliseconds, 1950, 2900); test.Reset(); watch.Restart(); test.Wait(); watch.Stop(); Assert.InRange(watch.ElapsedMilliseconds, 950, 2900); }
public void Create_Default() { var times = new List<TimeSpan> {TimeSpan.FromMilliseconds(100)}; var test = new QueueWait(times, GetCancel()); test.Wait(); }
public void Create_Default_Cancel() { var cancelSource = new CancellationTokenSource(); var times = new List<TimeSpan> { TimeSpan.FromMilliseconds(10000) }; var test = new QueueWait(times, GetCancel(cancelSource)); var watch = new Stopwatch(); watch.Start(); Task.Factory.StartNew(() => test.Wait()).ContinueWith(task => watch.Stop()); cancelSource.Cancel(); Assert.InRange(watch.ElapsedMilliseconds, 0, 5000); }