Ejemplo n.º 1
0
        public void TestCopyTo()
        {
            PopulateTestQueue();
            int?[] copyArray = new int?[SampleSize + 1];
            TestQueue.CopyTo(copyArray, 1);

            for (int i = 1; i < copyArray.Length; i++)
            {
                Assert.Equal(TestQueue.Dequeue(), copyArray[i]);
            }

            PopulateTestQueue();
            int?[] smallList = new int?[TestQueue.Count / 2];
            int?[] largeList = new int?[TestQueue.Count * 2];

            Assert.Throws <IndexOutOfRangeException>(() => TestQueue.CopyTo(largeList, -1));
            Assert.Throws <ArgumentOutOfRangeException>(() => TestQueue.CopyTo(smallList, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => TestQueue.CopyTo(largeList, largeList.Length - 2));
        }