예제 #1
0
        public void AddFiveItemsCopyToArray()
        {
            var linkedListQueueArray = new int[5];
            var arrayQueueArray      = new int[5];
            int linkedListQueueLast  = 0;
            int arrayQueueLast       = 0;

            for (int i = 1; i <= 5; i++)
            {
                linkedListQueue.Enqueue(i);
                arrayQueue.Enqueue(i);
            }
            foreach (var item in linkedListQueue.Get())
            {
                linkedListQueueLast = item;
            }

            foreach (var item in arrayQueue.Get())
            {
                arrayQueueLast = item;
            }

            linkedListQueue.CopyTo(linkedListQueueArray, 0);
            arrayQueue.CopyTo(arrayQueueArray, 0);

            Assert.AreEqual(linkedListQueueLast, 5, "invalid last element");
            Assert.AreEqual(arrayQueueLast, 5, "invalid last element");

            Assert.AreEqual(linkedListQueueArray[0], 1, "invalid element");
            Assert.AreEqual(arrayQueueArray[0], 1, "invalid element");

            Assert.AreEqual(linkedListQueueArray[4], 5, "invalid element");
            Assert.AreEqual(arrayQueueArray[4], 5, "invalid element");
        }