public virtual void TestTimeoutNext() { IPausableBlockingQueue4 queue = new PausableBlockingQueue(); Assert.IsFalse(queue.IsPaused()); queue.Pause(); Assert.IsTrue(queue.IsPaused()); object obj = new object(); queue.Add(obj); Assert.IsTrue(queue.HasNext()); Assert.IsNull(queue.TryNext()); queue.Resume(); Assert.AreSame(obj, queue.Next(50)); }
/// <exception cref="System.Exception"></exception> public virtual void TestDrainTo() { IPausableBlockingQueue4 queue = new PausableBlockingQueue(); queue.Add(new object()); queue.Add(new object()); queue.Pause(); Collection4 list = new Collection4(); Thread t = ExecuteAfter("Pausable queue drainer", 0, new _IRunnable_66(queue, list )); Runtime4.SleepThrowsOnInterrupt(200); lock (list) { Assert.AreEqual(0, list.Size()); } Assert.IsTrue(queue.HasNext()); queue.Resume(); t.Join(); lock (list) { Assert.AreEqual(2, list.Size()); } Assert.IsFalse(queue.HasNext()); }