コード例 #1
0
        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(""));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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..."));
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 private Logger()
 {
     queue = new LoggerQueue(SIZE);
     producers = new Semaphore(SIZE, SIZE); // Many producers
     consumers = new Semaphore(0, SIZE); // Only one consumer
 }
コード例 #6
0
 private Logger()
 {
     queue     = new LoggerQueue(SIZE);
     producers = new Semaphore(SIZE, SIZE); // Many producers
     consumers = new Semaphore(0, SIZE);    // Only one consumer
 }