System.Data.Tests.RowNotInTableExceptionTest.Generate C# (CSharp) Method

Generate() private method

private Generate ( ) : void
return void
        public void Generate()
        {
            var ds = new DataSet();
            ds.Tables.Add(DataProvider.CreateParentDataTable());
            ds.Tables.Add(DataProvider.CreateChildDataTable());
            ds.Relations.Add(new DataRelation("myRelation", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0]));

            DataRow drParent = ds.Tables[0].Rows[0];
            DataRow drChild = ds.Tables[1].Rows[0];
            drParent.Delete();
            drChild.Delete();
            ds.AcceptChanges();

            // RowNotInTableException - AcceptChanges
            Assert.Throws<RowNotInTableException>(() =>
            {
                drParent.AcceptChanges();
            });

            // RowNotInTableException - GetChildRows
            Assert.Throws<RowNotInTableException>(() =>
            {
                drParent.GetChildRows("myRelation");
            });

            // RowNotInTableException - ItemArray
            Assert.Throws<RowNotInTableException>(() => drParent.ItemArray);

            // RowNotInTableException - GetParentRows
            Assert.Throws<RowNotInTableException>(() => drChild.GetParentRows("myRelation"));

            // RowNotInTableException - RejectChanges
            Assert.Throws<RowNotInTableException>(() => drParent.RejectChanges());

            // RowNotInTableException - SetParentRow
            Assert.Throws<RowNotInTableException>(() => drChild.SetParentRow(ds.Tables[0].Rows[1]));
        }
    }
RowNotInTableExceptionTest