public void TestCountAndIsEmpty() { GenericController controller = new GenericController(); Assert.AreEqual(true, controller.IsEmpty()); controller.Enqueue(NewPacket(10, 0), 0); Assert.AreEqual(false, controller.IsEmpty()); controller.Enqueue(NewPacket(10, 0), 0); controller.Enqueue(NewPacket(10, 1), 1); controller.Enqueue(NewPacket(10, 1), 1); controller.Enqueue(NewPacket(10, 2), 2); controller.Enqueue(NewPacket(10, 3), 3); controller.Enqueue(NewPacket(10, 3), 3); controller.Enqueue(NewPacket(10, 4), 4); Assert.AreEqual(false, controller.IsEmpty()); Assert.AreEqual(8, controller.Count); for (int i = 0; i < 8; i++) { controller.Dequeue(); } Assert.AreEqual(true, controller.IsEmpty()); }
public void TestGenericController() { GenericController controller = new GenericController(); controller.Enqueue(NewPacket(1, 0), PacketPriority.MEDIUM); controller.Enqueue(NewPacket(2, 0), PacketPriority.LOW); controller.Enqueue(NewPacket(3, 0), PacketPriority.HIGH); controller.Enqueue(NewPacket(4, 0), PacketPriority.EMERGENT); controller.Enqueue(NewPacket(5, 0), PacketPriority.LOWEST); AssertPacket(controller.Peek(), 4, 0); AssertPacket(controller.Dequeue(), 4, 0); AssertPacket(controller.Dequeue(), 3, 0); AssertPacket(controller.Dequeue(), 1, 0); AssertPacket(controller.Peek(), 2, 0); AssertPacket(controller.Dequeue(), 2, 0); AssertPacket(controller.Peek(), 5, 0); AssertPacket(controller.Dequeue(), 5, 0); Assert.AreEqual(controller.Peek(), null); Assert.AreEqual(controller.Dequeue(), null); Assert.AreEqual(controller.Peek(), null); }
public void TestGenericControllerTooHighPriority2() { GenericController controller = new GenericController(); controller.Enqueue(NewPacket(1, 3), (PacketPriority)5); }
public void TestGenericControllerTooLowPriority2() { GenericController controller = new GenericController(); controller.Enqueue(NewPacket(1, -1), (PacketPriority)(-1)); }