Пример #1
0
        public void Dequeue_QueueContainsSeveralElements_DeletesReturnedElement()
        {
            //
            // Arrange.
            //
            bool   expectedResult = false;
            bool   actualResult   = false;
            string firstElement   = "First";
            QueueThroughLinkedList <string> queue = new QueueThroughLinkedList <string>();

            queue.Enqueue(firstElement);
            queue.Enqueue("Second");
            queue.Enqueue("Third");

            //
            // Act.
            //
            queue.Dequeue();
            string[] arrayOfLeftItems = new string[]
            {
                queue.Dequeue(),
                     queue.Dequeue()
            };
            actualResult = arrayOfLeftItems.Contains(firstElement);

            //
            // Assert.
            //
            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #2
0
        public void Dequeue_QueueIsEmpty_ThrowsInvalidOperationException()
        {
            //
            // Arrange.
            //
            QueueThroughLinkedList <string> queue = new QueueThroughLinkedList <string>();

            //
            // Act.
            //
            queue.Dequeue();
        }
Пример #3
0
        public void Dequeue_QueueContainsSeveralElements_ReturnsFirstElement()
        {
            //
            // Arrange.
            //
            string expectedResult = "First";
            string actualResult   = string.Empty;
            QueueThroughLinkedList <string> queue = new QueueThroughLinkedList <string>();

            queue.Enqueue(expectedResult);
            queue.Enqueue("Second");
            queue.Enqueue("Third");

            //
            // Act.
            //
            actualResult = queue.Dequeue();

            //
            // Assert.
            //
            Assert.AreEqual(expectedResult, actualResult);
        }