System.Data.Tests.DataRowCollectionTest.CopyTo C# (CSharp) Method

CopyTo() private method

private CopyTo ( ) : void
return void
        public void CopyTo()
        {
            _tbl.Columns.Add();
            _tbl.Columns.Add();
            _tbl.Columns.Add();

            DataRowCollection Rows = _tbl.Rows;

            Rows.Add(new object[] { "1", "1", "1" });
            Rows.Add(new object[] { "2", "2", "2" });
            Rows.Add(new object[] { "3", "3", "3" });
            Rows.Add(new object[] { "4", "4", "4" });
            Rows.Add(new object[] { "5", "5", "5" });
            Rows.Add(new object[] { "6", "6", "6" });
            Rows.Add(new object[] { "7", "7", "7" });

            DataRow[] dr = new DataRow[10];

            try
            {
                Rows.CopyTo(dr, 4);
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(ArgumentException), e.GetType());
                //Assert.Equal ("Destination array was not long enough.  Check destIndex and length, and the array's lower bounds.", e.Message);
            }

            dr = new DataRow[11];
            Rows.CopyTo(dr, 4);

            Assert.Null(dr[0]);
            Assert.Null(dr[1]);
            Assert.Null(dr[2]);
            Assert.Null(dr[3]);
            Assert.Equal("1", dr[4][0]);
            Assert.Equal("2", dr[5][0]);
            Assert.Equal("3", dr[6][0]);
            Assert.Equal("4", dr[7][0]);
            Assert.Equal("5", dr[8][0]);
            Assert.Equal("6", dr[9][0]);
        }