Пример #1
0
        public void LinkedListQueue()
        {
            var queue = new LinkedListQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);

            Assert.AreEqual(1, queue.Dequeue());
            Assert.AreEqual(2, queue.Dequeue());
            Assert.AreEqual(3, queue.Dequeue());
            Assert.AreEqual(4, queue.Dequeue());
            Assert.AreEqual(5, queue.Dequeue());
            Assert.AreEqual(true, queue.IsEmpty());
        }
Пример #2
0
        public void E1329()
        {
            LinkedListQueue<string> queue = new LinkedListQueue<string>();
            Assert.AreEqual(0, queue.Size);
            queue.Enqueue(new Node<string>(1));
            Assert.AreEqual(1, queue.Size);
            queue.Enqueue(new Node<string>(2));
            Assert.AreEqual(2, queue.Size);
            queue.Enqueue(new Node<string>(3));
            Assert.AreEqual(3, queue.Size);

            queue.Dequeue();
            Assert.AreEqual(2, queue.Size);
            queue.Dequeue();
            Assert.AreEqual(1, queue.Size);
            queue.Dequeue();
            Assert.AreEqual(0, queue.Size);
            Assert.IsTrue(queue.IsEmpty());

            try
            {
                queue.Dequeue();
                throw new ApplicationException("Test failed");
            }
            catch (Exception)
            { }
        }