public void QueueWithLinkedList_IsFull_should_return_true_when_queue_has_capacity_number_of_elements()
        {
            QueueWithLinkedList <int> qu2 = new QueueWithLinkedList <int>(2);

            qu2.Enqueue(1);
            qu2.Enqueue(3);

            Assert.AreEqual(true, qu2.IsFull());
        }
Пример #2
0
        private void Queue_Implementation_Using_Linkedlist_Click(object sender, EventArgs e)
        {
            QueueWithLinkedList list = new QueueWithLinkedList();

            Console.WriteLine("Checking Is Empty - " + list.IsEmpty());
            Console.WriteLine("Push 5 - "); list.Enqueue(5);
            Console.WriteLine("Push 4 - "); list.Enqueue(4);
            Console.WriteLine("Push 3 - "); list.Enqueue(3);

            Console.WriteLine("Pop 5 - " + list.Dequeue().data);
            Console.WriteLine("Peek 4 - " + list.Peek().data);
            Console.WriteLine("Pop 4 - " + list.Dequeue().data);
            Console.WriteLine("Checking Is Empty - " + list.IsEmpty());
            Console.WriteLine("Pop 3 - " + list.Dequeue().data);

            Console.WriteLine("Checking Is Empty - " + list.IsEmpty());
        }
        public void QueueWithLinkedList_IsFull_should_return_false_when_stack_has_less_elements()
        {
            QueueWithLinkedList <int> qu2 = new QueueWithLinkedList <int>(2);

            qu2.Enqueue(1);

            Assert.AreEqual(false, qu2.IsFull());
        }
        public void QueueWithLinkedList_Enqueue_should_throw_exception_when_queue_is_full()
        {
            QueueWithLinkedList <int> qu2 = new QueueWithLinkedList <int>(2);

            qu2.Enqueue(2);
            qu2.Enqueue(4);
            try
            {
                qu2.Enqueue(3);
                Assert.Fail();
            }
            catch (InvalidOperationException ex)
            {
                Assert.AreEqual("The queue is full", ex.Message);
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Пример #5
0
        public void Size_WhenCalled_ShouldReturnNumberOfItems(int range)
        {
            // Arrange
            for (var i = 1; i <= range; i++)
            {
                _queue.Enqueue(i);
            }

            // Act
            var result = _queue.Size;

            // Assert
            Assert.That(result, Is.EqualTo(range));
        }
        public void QueueWithLinkedList_IsEmpty_should_return_false_when_queue_is_not_empty()
        {
            qu.Enqueue(1);

            Assert.AreEqual(false, qu.IsEmpty());
        }