Beispiel #1
0
        public void TestEnqueueFullQueue()
        {
            // ARRANGE
            QueueLab.queue myQueue = new QueueLab.queue(1);
            String         item    = "queueItem";

            // ACT
            myQueue.enqueue(item);
            // ASSERT
            Assert.Throws <QueueLab.queueFullException>(() => myQueue.enqueue(item));
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            QueueLab.queue myQueue = new QueueLab.queue(2);
            String         item = "queueItem";
            String         actual, expected;

            expected = "queueItem3";
            myQueue.enqueue(item + "1");
            myQueue.enqueue(item + "2");
            myQueue.dequeue();
            myQueue.enqueue(item + "3");
            myQueue.dequeue();
            actual = myQueue.peek();
        }
Beispiel #3
0
        public void TestEnqueue()
        {
            // ARRANGE
            QueueLab.queue myQueue = new QueueLab.queue(2);
            String         item = "queueItem";
            String         actual, expected;

            expected = "queueItem1";
            // ACT
            myQueue.enqueue(item + "1");
            myQueue.enqueue(item + "2");
            actual = myQueue.peek();
            // ASSERT
            Assert.Equal(expected, actual);
        }
Beispiel #4
0
        public void TestSizeNonZero()
        {
            // ARRANGE
            QueueLab.queue myQueue = new QueueLab.queue(2);
            String         item = "queueItem";
            int            actual, expected;

            expected = 2;
            // ACT
            myQueue.enqueue(item + "1");
            myQueue.enqueue(item + "2");
            actual = myQueue.size();
            // ASSERT
            Assert.Equal(expected, actual);
        }
Beispiel #5
0
        public void TestPrintQueueWrapAround()
        {
            // ARRANGE
            QueueLab.queue myQueue = new QueueLab.queue(2);
            String         item = "queueItem";
            String         actual, expected;

            expected = "queueItem2\nqueueItem3\n";
            // ACT
            myQueue.enqueue(item + "1");
            myQueue.enqueue(item + "2");
            myQueue.dequeue();
            myQueue.enqueue(item + "3");
            actual = myQueue.printQueue();
            // ASSERT
            Assert.Equal(expected, actual);
        }
Beispiel #6
0
        public void TestIsFullTrue()
        {
            // ARRANGE
            QueueLab.queue myQueue = new QueueLab.queue(3);
            String         item    = "C# is Fun!";
            bool           actual;

            // ACT
            myQueue.enqueue(item);
            myQueue.enqueue(item);
            myQueue.enqueue(item);
            myQueue.dequeue();
            myQueue.enqueue(item);
            myQueue.dequeue();
            myQueue.enqueue(item);
            actual = myQueue.isFull();
            // ASSERT
            Assert.True(actual);
        }
Beispiel #7
0
        public void TestIsEmptyFalse()
        {
            // ARRANGE
            QueueLab.queue myQueue = new QueueLab.queue(1);
            String         item    = "C# is Fun!";
            bool           actual;

            // ACT
            myQueue.enqueue(item);
            actual = myQueue.isEmpty();
            // ASSERT
            Assert.False(actual);
        }
Beispiel #8
0
        public void TestPeek()
        {
            // ARRANGE
            QueueLab.queue myQueue = new QueueLab.queue(1);
            String         item = "queueItem";
            String         actual, expected;

            expected = item;
            // ACT
            myQueue.enqueue(item);
            actual = myQueue.peek();
            // ASSERT
            Assert.Equal(expected, actual);
        }