Ejemplo n.º 1
0
        public void GivenAnArrayOfObjectsUnordered()
        {
            // arrange
            var queue = new PriorityQueueLinkedList <DummyStringComparer2>();

            var t1 = new DummyStringComparer2 {
                StringOfX = "xxx"
            };
            var t2 = new DummyStringComparer2 {
                StringOfX = "x"
            };
            var t3 = new DummyStringComparer2 {
                StringOfX = "xxxxx"
            };
            var t4 = new DummyStringComparer2 {
                StringOfX = "xx"
            };
            var t5 = new DummyStringComparer2 {
                StringOfX = "xxxx"
            };

            DummyStringComparer2[] expected = { t2, t4, t1, t5, t3 };
            queue.Enqueue(t1);
            queue.Enqueue(t2);
            queue.Enqueue(t3);
            queue.Enqueue(t4);
            queue.Enqueue(t5);

            // act/assert
            Assert.IsTrue(queue.ToArray().SequenceEqual(expected));

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

            queue2.Enqueue(t1);
            queue2.Enqueue(t2);
            queue2.Enqueue(t3);
            queue2.Enqueue(t4);
            queue2.Enqueue(t5);

            // act/assert
            Assert.IsTrue(queue2.ToArray().SequenceEqual(expected));
        }
Ejemplo n.º 2
0
        public void GivenIntegersUnordered()
        {
            // arrange
            var queue    = new PriorityQueueLinkedList <int>();
            var expected = new[] { 3, 21, 100 };

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

            Assert.IsTrue(queue.ToArray().SequenceEqual(expected));

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

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

            Assert.IsTrue(queue2.ToArray().SequenceEqual(expected));
        }