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

Clear() private method

private Clear ( ) : void
return void
        public void Clear()
        {
            DataRowCollection Rows = _tbl.Rows;
            DataTable Table = new DataTable("child");
            Table.Columns.Add("first", typeof(int));
            Table.Columns.Add("second", typeof(string));

            _tbl.Columns.Add("first", typeof(int));
            _tbl.Columns.Add("second", typeof(float));

            string[] cols = new string[2];
            cols[0] = "1";
            cols[1] = "1,1";
            Rows.Add(cols);

            cols[0] = "2";
            cols[1] = "2,1";
            Rows.Add(cols);

            cols[0] = "3";
            cols[1] = "3,1";
            Rows.Add(cols);

            Assert.Equal(3, Rows.Count);
            Rows.Clear();

            Assert.Equal(0, Rows.Count);

            cols[0] = "1";
            cols[1] = "1,1";
            Rows.Add(cols);

            cols[0] = "2";
            cols[1] = "2,1";
            Rows.Add(cols);

            cols[0] = "3";
            cols[1] = "3,1";
            Rows.Add(cols);

            cols[0] = "1";
            cols[1] = "test";
            Table.Rows.Add(cols);

            cols[0] = "2";
            cols[1] = "test2";
            Table.Rows.Add(cols);

            cols[0] = "3";
            cols[1] = "test3";
            Table.Rows.Add(cols);

            DataSet Set = new DataSet();
            Set.Tables.Add(_tbl);
            Set.Tables.Add(Table);
            DataRelation Rel = new DataRelation("REL", _tbl.Columns[0], Table.Columns[0]);
            Set.Relations.Add(Rel);

            try
            {
                Rows.Clear();
                Assert.False(true);
            }
            catch (InvalidConstraintException)
            {
            }

            Assert.Equal(3, Table.Rows.Count);
            Table.Rows.Clear();
            Assert.Equal(0, Table.Rows.Count);
        }