Example #1
0
        /// <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());
        }
        public virtual void TestTimeoutNext()
        {
            ITimeoutBlockingQueue4 queue = new TimeoutBlockingQueue(300);

            queue.Pause();
            queue.Add(new object());
            queue.Check();
            Assert.IsNull(queue.TryNext());
            Runtime4.SleepThrowsOnInterrupt(500);
            queue.Check();
            Assert.IsNotNull(queue.TryNext());
        }