Beispiel #1
0
        public void DequeueTest()
        {
            // arrange
            var       queue    = new PriorityQueueLinkedList <int>();
            const int expected = 21;

            // act
            queue.Enqueue(21);
            queue.Enqueue(100);
            queue.Enqueue(3);

            queue.Dequeue();
            var result = queue.Dequeue();

            Assert.AreEqual(expected, result);

            // arrange
            var queue2 = new PriorityQueueBinaryTree <int>();

            // act
            queue2.Enqueue(21);
            queue2.Enqueue(100);
            queue2.Enqueue(3);

            queue2.Dequeue();
            result = queue2.Dequeue();

            Assert.AreEqual(expected, result);
        }
Beispiel #2
0
        public void DequeueWithNoItemsShouldThrowException()
        {
            // arrange
            var queue = new PriorityQueueLinkedList <int>();

            // act
            queue.Dequeue();

            // arrange
            var queue2 = new PriorityQueueBinaryTree <int>();

            // act
            queue2.Dequeue();
        }
        public void Test()
        {
            var queue = new PriorityQueueLinkedList <int>();

            queue.Enqueue(1);
            queue.Enqueue(3);
            queue.Enqueue(5);
            Assert.AreEqual("531", queue.GetValues());

            queue.Enqueue(4);
            Assert.AreEqual("5431", queue.GetValues());

            Assert.AreEqual(5, queue.Dequeue());
            Assert.AreEqual("431", queue.GetValues());

            queue.Enqueue(0);
            Assert.AreEqual("4310", queue.GetValues());
        }