public void TestEmptyFull()
        {
            LinkedBlockingQueue <String> q = new LinkedBlockingQueue <String>(2);

            Assert.IsTrue(q.IsEmpty());
            Assert.AreEqual(2, q.RemainingCapacity(), "should have room for 2");
            q.Add(one);
            Assert.IsFalse(q.IsEmpty());
            q.Add(two);
            Assert.IsFalse(q.IsEmpty());
            Assert.AreEqual(0, q.RemainingCapacity());
            Assert.IsFalse(q.Offer(three));
        }
        public void TestRemainingCapacity()
        {
            LinkedBlockingQueue <String> q = PopulatedDeque(SIZE);

            for (int i = 0; i < SIZE; ++i)
            {
                Assert.AreEqual(i, q.RemainingCapacity());
                Assert.AreEqual(SIZE - i, q.Size());
                q.Remove();
            }
            for (int i = 0; i < SIZE; ++i)
            {
                Assert.AreEqual(SIZE - i, q.RemainingCapacity());
                Assert.AreEqual(i, q.Size());
                q.Add(i.ToString());
            }
        }
        private LinkedBlockingQueue <String> PopulatedDeque(int n)
        {
            LinkedBlockingQueue <String> q = new LinkedBlockingQueue <String>(n);

            Assert.IsTrue(q.IsEmpty());
            for (int i = 0; i < n; i++)
            {
                Assert.IsTrue(q.Offer(i.ToString()));
            }
            Assert.IsFalse(q.IsEmpty());
            Assert.AreEqual(0, q.RemainingCapacity());
            Assert.AreEqual(n, q.Size());
            return(q);
        }
 public void TestAdd()
 {
     try
     {
         LinkedBlockingQueue <String> q = new LinkedBlockingQueue <String>(SIZE);
         for (int i = 0; i < SIZE; ++i)
         {
             Assert.IsTrue(q.Add(i.ToString()));
         }
         Assert.AreEqual(0, q.RemainingCapacity());
         q.Add(SIZE.ToString());
     }
     catch (IllegalStateException)
     {
     }
 }
 public void TestPut()
 {
     try
     {
         LinkedBlockingQueue <String> q = new LinkedBlockingQueue <String>(SIZE);
         for (int i = 0; i < SIZE; ++i)
         {
             q.Put(i.ToString());
             Assert.IsTrue(q.Contains(i.ToString()));
         }
         Assert.AreEqual(0, q.RemainingCapacity());
     }
     catch (Exception)
     {
         UnexpectedException();
     }
 }