Esempio n. 1
0
        public void Peek_PushTwoItems_ReturnsHeadItem()
        {
            var queue = new ArrayQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);

            Assert.AreEqual(1, queue.Peek());
        }
Esempio n. 2
0
        public void Pop_EmptyStack_ThrowsException()
        {
            var queue = new ArrayQueue <int>();

            Assert.Throws <InvalidOperationException>(() =>
            {
                queue.Dequeue();
            });
        }
Esempio n. 3
0
        public void Count_PushOneItem_ReturnsOne()
        {
            var queue = new ArrayQueue <int>();

            queue.Enqueue(1);

            Assert.AreEqual(1, queue.Count);
            Assert.IsFalse(queue.IsEmpty);
        }
Esempio n. 4
0
        public void Peek_PushTwoItemsAndPop_ReturnsHeadElement()
        {
            var queue = new ArrayQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);

            queue.Dequeue();

            Assert.AreEqual(2, queue.Peek());
        }
Esempio n. 5
0
        public void Capacity_EnqueueManyItems_DoubledCapacity()
        {
            var queue = new ArrayQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);

            Assert.AreEqual(8, queue.Capacity);
        }
Esempio n. 6
0
        static void TestArrayQueue()
        {
            ArrayQueue queue = new ArrayQueue(5);

            queue.Enqueue(10);
            queue.Enqueue(20);
            queue.Enqueue(30);

            //Console.WriteLine(queue.Dequeue());

            queue.Dequeue();
            queue.Dequeue();

            queue.Enqueue(40);
            queue.Enqueue(50);
            queue.Enqueue(60);
            queue.Enqueue(70);

            queue.Dequeue();
            queue.Enqueue(80);


            Console.WriteLine(queue);
        }
Esempio n. 7
0
        public void IsEmpty_EmptyQueue_ReturnsTrue()
        {
            var queue = new ArrayQueue <int>();

            Assert.IsTrue(queue.IsEmpty);
        }