public void AddExceptions()
{
DataTable Table = new DataTable("test_table");
DataTable Table2 = new DataTable("test_table2");
DataColumnCollection Cols = Table.Columns;
DataColumn C = null;
try
{
Cols.Add(C);
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(ArgumentNullException), e.GetType());
}
C = new DataColumn("test");
Cols.Add(C);
try
{
Cols.Add(C);
Assert.False(true);
}
catch (ArgumentException e)
{
// Assert.Equal (typeof (ArgumentException), e.GetType ());
// Assert.Equal ("Column 'test' already belongs to this or another DataTable.", e.Message);
}
try
{
Table2.Columns.Add(C);
Assert.False(true);
}
catch (ArgumentException e)
{
// Assert.Equal (typeof (ArgumentException), e.GetType ());
// Assert.Equal ("Column 'test' already belongs to this or another DataTable.", e.Message);
}
DataColumn C2 = new DataColumn("test");
try
{
Cols.Add(C2);
Assert.False(true);
}
catch (DuplicateNameException e)
{
// Assert.Equal (typeof (DuplicateNameException), e.GetType ());
// Assert.Equal ("A DataColumn named 'test' already belongs to this DataTable.", e.Message);
}
try
{
Cols.Add("test2", typeof(string), "substring ('fdsafewq', 2)");
Assert.False(true);
}
catch (InvalidExpressionException e)
{
// Assert.True (e is InvalidExpressionException);
// Assert.Equal ("Expression 'substring ('fdsafewq', 2)' is invalid.", e.Message);
}
}