private void testDequeue(BasicQueue <DSInteger> the_queue) { //make sure the elements are removed with a LIFO methodology Assert.AreEqual(100, the_queue.dequeue().value); Assert.AreEqual(50, the_queue.dequeue().value); Assert.AreEqual(200, the_queue.dequeue().value); Assert.AreEqual(25, the_queue.dequeue().value); Assert.AreEqual(400, the_queue.dequeue().value); //make sure no remain after all dequeues Assert.AreEqual(true, the_queue.isEmpty()); }
private void testSize(BasicQueue <DSInteger> the_queue) { Assert.AreEqual(5, the_queue.size()); the_queue.dequeue(); Assert.AreEqual(4, the_queue.size()); the_queue.clear(); Assert.AreEqual(0, the_queue.size()); }
private void testClear(BasicQueue <DSInteger> the_queue) { //make sure there are items Assert.AreEqual(false, the_queue.isEmpty()); //make sure they are cleared the_queue.clear(); Assert.AreEqual(true, the_queue.isEmpty()); Assert.AreEqual(null, the_queue.dequeue()); }
private void testPoll(BasicQueue <DSInteger> the_queue) { //assert that calling poll does not remove the first item Assert.AreEqual(100, the_queue.poll().value); Assert.AreEqual(100, the_queue.poll().value); //make sure that poll works even after a dequeue() operation the_queue.dequeue(); Assert.AreEqual(50, the_queue.poll().value); }
private void testEnqueue(BasicQueue <DSInteger> the_queue) { //make sure the last element removed is the last one added DSInteger next = null, last = null; while ((next = the_queue.dequeue()) != null) { last = next; } Assert.AreEqual(400, last.value); }