public void Remove()
{
_tbl.Columns.Add();
_tbl.Columns.Add();
_tbl.Columns.Add();
DataRowCollection Rows = _tbl.Rows;
Rows.Add(new object[] { "a", "aa", "aaa" });
Rows.Add(new object[] { "b", "bb", "bbb" });
Rows.Add(new object[] { "c", "cc", "ccc" });
Rows.Add(new object[] { "d", "dd", "ddd" });
Assert.Equal(4, _tbl.Rows.Count);
Rows.Remove(_tbl.Rows[1]);
Assert.Equal(3, _tbl.Rows.Count);
Assert.Equal("a", _tbl.Rows[0][0]);
Assert.Equal("c", _tbl.Rows[1][0]);
Assert.Equal("d", _tbl.Rows[2][0]);
try
{
Rows.Remove(null);
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(IndexOutOfRangeException), e.GetType());
// Never premise English.
//Assert.Equal ("The given datarow is not in the current DataRowCollection.", e.Message);
}
DataRow Row = new DataTable().NewRow();
try
{
Rows.Remove(Row);
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(IndexOutOfRangeException), e.GetType());
// Never premise English.
//Assert.Equal ("The given datarow is not in the current DataRowCollection.", e.Message);
}
try
{
Rows.RemoveAt(-1);
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(IndexOutOfRangeException), e.GetType());
// Never premise English.
//Assert.Equal ("There is no row at position -1.", e.Message);
}
try
{
Rows.RemoveAt(64);
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(IndexOutOfRangeException), e.GetType());
// Never premise English.
//Assert.Equal ("There is no row at position 64.", e.Message);
}
Rows.RemoveAt(0);
Rows.RemoveAt(1);
Assert.Equal(1, Rows.Count);
Assert.Equal("c", Rows[0][0]);
}