Ejemplo n.º 1
0
        [Test] public virtual void PeekSucceedsWhenQueueIsNotEmpty()
        {
            var queue  = NewQueueFilledWithSample();
            var unique = Samples.CountAll();

            for (int i = 0; i < SampleSize; ++i)
            {
                T value;
                Assert.IsTrue(queue.Peek(out value));
                AssertRetrievedResult(value, i);
                queue.Remove();
                var count = unique[value];
                if (count > 1)
                {
                    unique[value] = count - 1;
                    continue;
                }
                T next;
                if (queue.Peek(out next))
                {
                    Assert.That(next, Is.Not.EqualTo(value));
                }
            }
        }