Ejemplo n.º 1
0
        public void Dequeue_UntilEmptyQueue_ReturnsItemsInQueue()
        {
            var queue  = new FixedBasedQueue <int>(2);
            var result = queue.Enqueue(10);

            result = queue.Enqueue(100);


            var item = queue.Dequeue();

            //dequeued item should be 10
            Assert.IsTrue(item == 10);

            //current size should be 1;
            Assert.IsTrue(queue.CurrentSize == 1);

            item = queue.Dequeue();
            //dequeued item should be 100
            Assert.IsTrue(item == 100);

            //current size should be 0 after dequeuing 100
            Assert.IsTrue(queue.CurrentSize == 0);

            //queue should be empty
            Assert.IsTrue(queue.IsEmpty() == true);
        }
Ejemplo n.º 2
0
        public void Dequeue_EmptyQueue_ReturnsDefaultValue()
        {
            var intQueue     = new FixedBasedQueue <int>();
            var intQueueItem = intQueue.Dequeue();

            //check to see if the int item returned is the default value of int which is 0
            Assert.IsTrue(intQueueItem == default(int));

            var stringQueue     = new FixedBasedQueue <string>();
            var stringQueueItem = stringQueue.Dequeue();

            //check to see if the string item returned is the default value of string which is null
            Assert.IsTrue(stringQueueItem == default(string));
        }
Ejemplo n.º 3
0
        public void Deqeue_SingleElement_ReturnsItemInQueue()
        {
            var queue  = new FixedBasedQueue <int>();
            var result = queue.Enqueue(10);
            var item   = queue.Dequeue();

            //current size should be 0;
            Assert.IsTrue(queue.CurrentSize == 0);

            //result should be true of the En-queuing
            Assert.IsTrue(result == true);

            //dequeued item should be 10
            Assert.IsTrue(item == 10);
        }