public void TestOffer()
        {
            LinkedBlockingQueue <String> q = new LinkedBlockingQueue <String>(1);

            Assert.IsTrue(q.Offer(zero));
            Assert.IsFalse(q.Offer(one));
        }
 public void TestOfferNull()
 {
     try
     {
         LinkedBlockingQueue <String> q = new LinkedBlockingQueue <String>();
         q.Offer(null);
         ShouldThrow();
     }
     catch (NullReferenceException) {}
 }
        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));
        }
        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);
        }