Exemplo n.º 1
0
        public void TestEnqueue_OneItem()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            queue.Enqueue(1);

            Assert.AreEqual(1, queue.Count);
            Assert.AreEqual("1", queue.ToString());
        }
Exemplo n.º 2
0
        public void TestToString_NonEmptyQueue()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int queueCount = 5;

            for (int i = 0; i < queueCount; i++)
            {
                queue.Enqueue(i);
            }

            Assert.AreEqual("01234", queue.ToString());
        }
Exemplo n.º 3
0
        public void TestEnqueue_TenItems()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int queueCount = 10;

            for (int i = 0; i < queueCount; i++)
            {
                queue.Enqueue(i);
            }

            Assert.AreEqual(queueCount, queue.Count);
            Assert.AreEqual("0123456789", queue.ToString());
        }
Exemplo n.º 4
0
        public void TestDequeue_OneItem()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int queueCount = 5;

            for (int i = 0; i < queueCount; i++)
            {
                queue.Enqueue(i);
            }

            int dequeuedItem = queue.Dequeue();

            Assert.AreEqual(0, dequeuedItem);
            Assert.AreEqual(4, queue.Count);
            Assert.AreEqual("1234", queue.ToString());
        }
Exemplo n.º 5
0
        public void TestToArray_NonEmptyQueue()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int queueCount = 10;

            for (int i = 0; i < queueCount; i++)
            {
                queue.Enqueue(i);
            }

            int[] arr = queue.ToArray();

            Assert.AreEqual(10, arr.Length);
            Assert.AreEqual(queue.Peek(), arr[0]);
            Assert.AreEqual(queue.ToString(), string.Join(string.Empty, arr));
        }
Exemplo n.º 6
0
        public void TestClone_NonEmptyQueue()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int queueCount = 5;

            for (int i = 0; i < queueCount; i++)
            {
                queue.Enqueue(i);
            }

            CustomQueue <int> clone = (CustomQueue <int>)queue.Clone();

            queue.Dequeue();

            Assert.AreEqual(5, clone.Count);
            Assert.AreEqual("01234", clone.ToString());
            Assert.AreEqual(4, queue.Count);
        }
Exemplo n.º 7
0
        public void TestDequeue_MultipleItems()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int queueCount = 10;

            for (int i = 0; i < queueCount; i++)
            {
                queue.Enqueue(i);
            }

            for (int i = 0; i < 5; i++)
            {
                int dequeuedItem = queue.Dequeue();
                Assert.AreEqual(i, dequeuedItem);
            }

            Assert.AreEqual(5, queue.Count);
            Assert.AreEqual("56789", queue.ToString());
        }
Exemplo n.º 8
0
        public void TestToString_EmptyQueue()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            Assert.AreEqual(string.Empty, queue.ToString());
        }