Exemplo n.º 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());
        }
Exemplo n.º 2
0
        public virtual void TestStop()
        {
            IPausableBlockingQueue4 queue = new PausableBlockingQueue();

            queue.Pause();
            ExecuteAfter("Pausable queue stopper", 200, new _IRunnable_40(queue));
            Assert.Expect(typeof(BlockingQueueStoppedException), new _ICodeBlock_46(queue));
        }
Exemplo n.º 3
0
        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));
        }