public void add_single_entry() { LoggerQueue queue = new LoggerQueue(20); Assert.IsTrue(queue.add("Testing testing testing...")); Assert.IsFalse(queue.add(null)); Assert.IsFalse(queue.add("")); }
public void pop_single_entry() { LoggerQueue queue = new LoggerQueue(1); queue.add("test"); Assert.IsTrue(queue.isFull()); Console.WriteLine(queue.pop()); Assert.IsTrue(queue.isEmpty()); }
public void fill_queue() { LoggerQueue queue = new LoggerQueue(20); for (int i = 0; i < queue.Size; i++) { queue.add("Testing testing testing..."); } Assert.IsTrue(queue.isFull()); Assert.IsFalse(queue.add("Just one more...")); }
public void pop_multiple_entries() { LoggerQueue queue = new LoggerQueue(20); int add = 0; while (add < 10) { queue.add(String.Format("Test {0}", ++add)); } int pop = 0; while (pop < 10) { Assert.AreEqual(queue.pop(), String.Format("Test {0}", ++pop)); } }
private Logger() { queue = new LoggerQueue(SIZE); producers = new Semaphore(SIZE, SIZE); // Many producers consumers = new Semaphore(0, SIZE); // Only one consumer }