public void LoadDataException()
{
DataTable table = new DataTable();
DataColumn col = new DataColumn();
col.ColumnName = "Id";
col.DataType = typeof(int);
col.DefaultValue = 47;
table.Columns.Add(col);
UniqueConstraint uc = new UniqueConstraint("UK1", table.Columns[0]);
table.Constraints.Add(uc);
col = new DataColumn();
col.ColumnName = "Name";
col.DataType = typeof(string);
col.DefaultValue = "Hello";
table.Columns.Add(col);
table.BeginLoadData();
object[] row = { 147, "Abc" };
DataRow newRow = table.LoadDataRow(row, true);
object[] row1 = { 147, "Efg" };
DataRow newRow1 = table.LoadDataRow(row1, true);
object[] row2 = { 143, "Hij" };
DataRow newRow2 = table.LoadDataRow(row2, true);
try
{
table.EndLoadData();
Assert.False(true);
}
catch (ConstraintException)
{
}
}