public static void CopyTo_DequeueThenEnqueue()
{
var queue1 = new Queue(100);
// Insert 50 items in the Queue
for (int i = 0; i < 50; i++)
{
queue1.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++)
{
queue1.Enqueue(i + 50);
queue1.Dequeue();
}
var array = new object[queue1.Count];
queue1.CopyTo(array, 0);
Assert.Equal(queue1.Count, array.Length);
for (int i = 0; i < queue1.Count; i++)
{
Assert.Equal(queue1.Dequeue(), array[i]);
}
}