public void Expression_Exceptions() { DataTable dt = DataProvider.CreateParentDataTable(); try { dt.Columns[0].Unique = true; dt.Columns[0].Expression = "sum(" + dt.Columns[0].ColumnName + ")"; Assert.Fail("dccee#1: Expression failed to throw ArgmentException"); } catch (ArgumentException) {} catch (AssertionException exc) { throw exc; } catch (Exception exc) { Assert.Fail("dccee#2: Expression. Wrong exception type. Got:" + exc); } try { DataTable dt1 = DataProvider.CreateParentDataTable(); dt1.Columns[0].AutoIncrement = true; dt1.Columns[0].Expression = "sum(" + dt1.Columns[0].ColumnName + ")"; Assert.Fail("dccee#3: Expression failed to throw ArgmentException"); } catch (ArgumentException) {} catch (AssertionException exc) { throw exc; } catch (Exception exc) { Assert.Fail("dccee#4: Expression. Wrong exception type. Got:" + exc); } try { DataTable dt1 = DataProvider.CreateParentDataTable(); dt1.Constraints.Add(new UniqueConstraint(dt1.Columns[0], false)); dt1.Columns[0].Expression = "count(" + dt1.Columns[0].ColumnName + ")"; Assert.Fail("dccee#5: Expression failed to throw ArgmentException"); } catch (ArgumentException) {} catch (AssertionException exc) { throw exc; } catch (Exception exc) { Assert.Fail("dccee#6: Expression. Wrong exception type. Got:" + exc); } try { DataTable dt1 = DataProvider.CreateParentDataTable(); dt1.Columns[0].Expression = "CONVERT(" + dt1.Columns[1].ColumnName + ",'System.Int32')"; Assert.Fail("dccee#7: Expression failed to throw FormatException"); } catch (FormatException) {} catch (AssertionException exc) { throw exc; } catch (Exception exc) { Assert.Fail("dccee#8: Expression. Wrong exception type. Got:" + exc); } try { DataTable dt1 = DataProvider.CreateParentDataTable(); dt1.Columns[0].Expression = "CONVERT(" + dt1.Columns[0].ColumnName + ",'System.DateTime')"; Assert.Fail("dccee#9: Expression failed to throw ArgmentException"); } catch (ArgumentException) {} catch (AssertionException exc) { throw exc; } catch (Exception exc) { Assert.Fail("dccee#10: Expression. Wrong exception type. Got:" + exc); } try { DataTable dt1 = DataProvider.CreateParentDataTable(); dt1.Columns[1].Expression = "CONVERT(" + dt1.Columns[0].ColumnName + ",'System.DateTime')"; Assert.Fail("dccee#11: Expression failed to throw InvalidCastException"); } catch (InvalidCastException) {} catch (AssertionException exc) { throw exc; } catch (Exception exc) { Assert.Fail("dccee#12: Expression. Wrong exception type. Got:" + exc); } try { DataTable dt1 = DataProvider.CreateParentDataTable(); dt1.Columns[1].Expression = "SUBSTRING(" + dt1.Columns[2].ColumnName + ",60000000000,2)"; Assert.Fail("dccee#13: Expression failed to throw OverflowException"); } catch (OverflowException) {} catch (AssertionException exc) { throw exc; } catch (Exception exc) { Assert.Fail("dccee#14: Expression. Wrong exception type. Got:" + exc); } }