public static void Clone_DequeueThenEnqueue()
{
var queue1 = new Queue(100);
Helpers.PerformActionOnAllQueueWrappers(queue1, queue2 =>
{
// Insert 50 items in the Queue
for (int i = 0; i < 50; i++)
{
queue2.Enqueue(i);
}
// Insert and Remove 75 items in the Queue. This should wrap the queue
// where there is 25 at the end of the array and 25 at the beginning
for (int i = 0; i < 75; i++)
{
queue2.Enqueue(i + 50);
queue2.Dequeue();
}
Queue queClone = (Queue)queue2.Clone();
Assert.Equal(50, queClone.Count);
Assert.Equal(75, queClone.Dequeue());
// Add an item to the Queue
queClone.Enqueue(100);
Assert.Equal(50, queClone.Count);
Assert.Equal(76, queClone.Dequeue());
});
}