示例#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);
        }