public void TryPeek_SomethingQueued_OutputsSameValueWhenCalledTwice()
        {
            long capacity = Random.Next(10, MaxCapacity);
            int  enqueued = Random.Next();
            CyclicConcurrentQueue <int> cyclicConcurrentQueue = CreateCyclicConcurrentQueue <int>(capacity);

            cyclicConcurrentQueue.Enqueue(enqueued);
            int peeked1, peeked2;

            cyclicConcurrentQueue.TryPeek(out peeked1);
            cyclicConcurrentQueue.TryPeek(out peeked2);
            Assert.AreEqual(peeked1, peeked2);
        }
        public void TryPeek_NothingQueued_ReturnsFalse()
        {
            long capacity = Random.Next(10, MaxCapacity);
            CyclicConcurrentQueue <int> cyclicConcurrentQueue = CreateCyclicConcurrentQueue <int>(capacity);
            int peeked;

            Assert.IsFalse(cyclicConcurrentQueue.TryPeek(out peeked));
        }
        public void Count_SomethingPeekedSuccessfully_ValueStaysTheSame()
        {
            List <int> initialValues = Enumerable.Range(1, Random.Next(10, 10000)).Select(n => Random.Next()).ToList();
            long       capacity      = Random.Next(10, MaxCapacity);
            CyclicConcurrentQueue <int> cyclicConcurrentQueue = CreateCyclicConcurrentQueue(initialValues, capacity);
            int previousCount = cyclicConcurrentQueue.Count();
            int peeked;

            if (cyclicConcurrentQueue.TryPeek(out peeked))
            {
                Assert.AreEqual(previousCount, cyclicConcurrentQueue.Count());
            }
            else
            {
                Assert.Inconclusive("Could not successfully peek at an item.");
            }
        }
        public void TryPeek_ItemsQueued_OutputsLeastRecentlyEnqueuedItem()
        {
            long capacity = Random.Next(10, MaxCapacity);
            //Note: Using random choice for each number takes too long
            IEnumerable <int> enqueuedItems = Enumerable.Range(1, Random.Next(2, (int)capacity - 1));
            //.Select(n=>Random.Next());
            CyclicConcurrentQueue <int> cyclicConcurrentQueue = CreateCyclicConcurrentQueue <int>(capacity);
            int firstItem = Random.Next();

            cyclicConcurrentQueue.Enqueue(firstItem);
            foreach (int enqueuedItem in enqueuedItems)
            {
                cyclicConcurrentQueue.Enqueue(enqueuedItem);
            }
            int peeked;

            cyclicConcurrentQueue.TryPeek(out peeked);
            Assert.AreEqual(firstItem, peeked);
        }