Esempio n. 1
0
 public void TimeTilNext()
 {
     var queue = new SynchronousCommandQueue();
     queue.Run();
     Action action = () => Assert.Fail("Should not execute");
     using (var timer = new ThreadPoolScheduler())
     {
         long now = 0;
         long span = 0;
         timer.QueueEvent(new SingleEvent(500, () => queue.Enqueue(action), now));
         Assert.IsTrue(timer.GetNextScheduledTime(ref span, 0));
         Assert.AreEqual(500, span);
         Assert.IsTrue(timer.GetNextScheduledTime(ref span, 499));
         Assert.AreEqual(1, span);
         Assert.IsFalse(timer.GetNextScheduledTime(ref span, 500));
         Assert.AreEqual(0, span);
     }
 }
Esempio n. 2
0
 public void TimeTilNextNothingQueued()
 {
     using (var timer = new ThreadPoolScheduler())
     {
         long result = 0;
         Assert.IsFalse(timer.GetNextScheduledTime(ref result, 100));
         Assert.AreEqual(0, result);
     }
 }