System.Data.Tests.ForeignKeyConstraintTest.ViolationTest C# (CSharp) Метод

ViolationTest() приватный Метод

private ViolationTest ( ) : void
Результат void
        public void ViolationTest()
        {
            Assert.Throws<ArgumentException>(() =>
            {
                DataTable parent = _ds.Tables[0];
                DataTable child = _ds.Tables[1];

                parent.Rows.Add(new object[] { 1, 1, 1 });
                child.Rows.Add(new object[] { 2, 2, 2 });

                try
                {
                    child.Constraints.Add(new ForeignKeyConstraint(parent.Columns[0],
                                              child.Columns[0])
                                   );
                }
                finally
                {
                    // clear the rows for further testing
                    _ds.Clear();
                }
            });
        }