public void SelectExceptions()
{
DataTable T = new DataTable("test");
DataColumn C = new DataColumn("name");
T.Columns.Add(C);
C = new DataColumn("age");
C.DataType = typeof(int);
T.Columns.Add(C);
C = new DataColumn("id");
T.Columns.Add(C);
for (int i = 0; i < 100; i++)
{
DataRow Row = T.NewRow();
Row[0] = "human" + i;
Row[1] = i;
Row[2] = i;
T.Rows.Add(Row);
}
try
{
T.Select("name = human1");
Assert.False(true);
}
catch (EvaluateException e)
{
// column name human not found
Assert.Equal(typeof(EvaluateException), e.GetType());
}
Assert.Equal(1, T.Select("id = '12'").Length);
Assert.Equal(1, T.Select("id = 12").Length);
try
{
T.Select("id = 1k3");
Assert.False(true);
}
catch (SyntaxErrorException e)
{
// no operands after k3 operator
Assert.Equal(typeof(SyntaxErrorException), e.GetType());
}
}