Ejemplo n.º 1
0
        public void EmptyConstructorAndEmptyQueueTest()
        {
            FastQueue <int> q = new FastQueue <int>();

            Assert.IsTrue(q.Count == 0, "Count is non-zero!");
            Assert.IsTrue(!q.Any(), "FastQueue has a member when empty!");

            q.Clear();

            Assert.IsTrue(q.Count() == 0, "Count is non-zero!");
            Assert.IsTrue(!q.Any(), "FastQueue has a member when empty!");

            bool looped = false;

            foreach (int i in q)
            {
                looped = true;
            }
            Assert.IsTrue(!looped, "FastQueue looped even though empty!");

            Assert.ThrowsException <InvalidOperationException>(() => q.Dequeue(), "FastQueue didn't throw InvalidOperationException on empty Dequeue()");

            Assert.ThrowsException <InvalidOperationException>(() => q.Peek(), "FastQueue didn't throw InvalidOperationException on empty Peek()");
        }