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_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());
        }
 public void QueueWithLinkedList_Constructor_should_throw_exception_when_capacity_is_zero()
 {
     try
     {
         QueueWithLinkedList <int> qu2 = new QueueWithLinkedList <int>(0);
         Assert.Fail();
     }
     catch (ArgumentOutOfRangeException)
     {
         Assert.IsTrue(true);
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
Exemple #4
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_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();
            }
        }
Exemple #6
0
 public void SetUp()
 {
     _queue = new QueueWithLinkedList <int>();
 }