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 Enqueue_MaxSize_ReturnsTrue()
        {
            var queue  = new FixedBasedQueue <int>(2);
            var result = queue.Enqueue(19);

            result = queue.Enqueue(20);

            Assert.IsTrue(result == true);
            Assert.IsTrue(queue.CurrentSize == queue.MaxSize);
        }
Ejemplo n.º 3
0
        public void Clear_NonEmptyQueue_CurrentSizeIsZero()
        {
            var queue = new FixedBasedQueue <int>();

            queue.Enqueue(10);
            queue.Clear();

            Assert.IsTrue(queue.CurrentSize == 0);
        }
Ejemplo n.º 4
0
        public void Isfull_ReturnFalse()
        {
            var queue = new FixedBasedQueue <int>(2);

            queue.Enqueue(10);
            var isFull = queue.IsFull();

            Assert.IsTrue(queue.CurrentSize == 1);
            Assert.IsTrue(isFull == false);
        }
Ejemplo n.º 5
0
        public void IsEmpty_ReturnsFalse()
        {
            var queue = new FixedBasedQueue <int>();

            queue.Enqueue(10);
            var result = queue.IsEmpty();

            Assert.IsTrue(result == false);
            Assert.IsTrue(queue.CurrentSize == 1);
        }
Ejemplo n.º 6
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);
        }