public void EnqueueAndDequeueElements()
 {
     WaitNode node = new WaitNode();
     WaitNode node1 = new WaitNode();
     FIFOWaitQueue queue = new FIFOWaitQueue();
     Assert.AreEqual(null, queue.Dequeue());
     queue.Enqueue(node1);
     queue.Enqueue(node);
     Assert.AreEqual(2, queue.Length);
     Assert.IsTrue(queue.HasNodes);
     Assert.AreEqual(node1, queue.Dequeue());
     Assert.AreEqual(node, queue.Dequeue());
     Assert.IsFalse(queue.HasNodes);
 }
Пример #2
0
        public void EnqueueAndDequeueElements()
        {
            WaitNode      node  = new WaitNode();
            WaitNode      node1 = new WaitNode();
            FIFOWaitQueue queue = new FIFOWaitQueue();

            Assert.AreEqual(null, queue.Dequeue());
            queue.Enqueue(node1);
            queue.Enqueue(node);
            Assert.AreEqual(2, queue.Length);
            Assert.IsTrue(queue.HasNodes);
            Assert.AreEqual(node1, queue.Dequeue());
            Assert.AreEqual(node, queue.Dequeue());
            Assert.IsFalse(queue.HasNodes);
        }
 public void WaitingThreads()
 {
     WaitNode node = new WaitNode();
     FIFOWaitQueue queue = new FIFOWaitQueue();
     Assert.AreEqual(0, queue.WaitingThreads.Count);
     Assert.IsFalse(queue.IsWaiting(Thread.CurrentThread));
     queue.Enqueue(node);
     Assert.AreEqual(1, queue.WaitingThreads.Count);
     Assert.IsTrue(queue.IsWaiting(Thread.CurrentThread));
 }
Пример #4
0
        public void WaitingThreads()
        {
            WaitNode      node  = new WaitNode();
            FIFOWaitQueue queue = new FIFOWaitQueue();

            Assert.AreEqual(0, queue.WaitingThreads.Count);
            Assert.IsFalse(queue.IsWaiting(Thread.CurrentThread));
            queue.Enqueue(node);
            Assert.AreEqual(1, queue.WaitingThreads.Count);
            Assert.IsTrue(queue.IsWaiting(Thread.CurrentThread));
        }