コード例 #1
0
        public void IndexedCollection_CopyToNullArray()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            TestObject[] array = null;
            collection.CopyTo(array, 0);
        }
コード例 #2
0
        public void IndexedCollection_CopyToNotEnoughSpace()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            var array = new TestObject[count];

            collection.CopyTo(array, 1);
        }
コード例 #3
0
        public void IndexedCollection_CopyToSuccess()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            var array = new TestObject[count];

            collection.CopyTo(array, 0);

            for (int i = 0; i < array.Length; ++i)
            {
                var item = array[i];
                Assert.IsNotNull(item);
                Assert.AreEqual(i, item.Sequence);
                Assert.AreEqual($"Test{i}", item.Name);
            }
        }