System.Text.RegularExpressions.Tests.GroupCollectionTests.ICollection_CopyTo_Invalid C# (CSharp) Method

ICollection_CopyTo_Invalid() private method

private ICollection_CopyTo_Invalid ( ) : void
return void
        public static void ICollection_CopyTo_Invalid()
        {
            Regex regex = new Regex("e");
            ICollection collection = regex.Match("aaabbccccccccccaaaabc").Groups;

            // Array is null
            Assert.Throws<ArgumentNullException>("array", () => collection.CopyTo(null, 0));

            // Array is multidimensional
            Assert.Throws<ArgumentException>(null, () => collection.CopyTo(new object[10, 10], 0));

            // Array has a non-zero lower bound
            Array o = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 });
            Assert.Throws<IndexOutOfRangeException>(() => collection.CopyTo(o, 0));

            // Index < 0
            Assert.Throws<IndexOutOfRangeException>(() => collection.CopyTo(new object[collection.Count], -1));

            // Invalid index + length
            Assert.Throws<IndexOutOfRangeException>(() => collection.CopyTo(new object[collection.Count], 1));
            Assert.Throws<IndexOutOfRangeException>(() => collection.CopyTo(new object[collection.Count + 1], 2));
        }