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

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

            Assert.IsTrue(queue.MaxSize == 100);
            Assert.IsTrue(queue.CurrentSize == 0);
        }
Ejemplo n.º 3
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.º 4
0
        public void Clear_EmptyQueue_CurrentSizeIsZero()
        {
            var queue = new FixedBasedQueue <int>();

            queue.Clear();

            Assert.IsTrue(queue.CurrentSize == 0);
        }
Ejemplo n.º 5
0
        public void IsEmpty_ReturnsTrue()
        {
            var queue  = new FixedBasedQueue <int>();
            var result = queue.IsEmpty();

            Assert.IsTrue(result == true);
            Assert.IsTrue(queue.CurrentSize == 0);
        }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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);
        }