DataColumnExpressionTest.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Data;
  3. using NUnit.Framework;
  4. namespace Monotests_Mono.Data.SqlExpressions
  5. {
  6. [TestFixture]
  7. public class DataColumnExprTest
  8. {
  9. [Test]
  10. public void TestDataColumnExpr1 ()
  11. {
  12. DataTable table = new DataTable ();
  13. table.Columns.Add ("Col_0.Value", Type.GetType ("System.Int32"));
  14. table.Columns.Add ("Col_1", Type.GetType ("System.Int32"));
  15. table.Columns.Add ("Result", Type.GetType ("System.Int32"), "IIF(Col_0.Value > 10, Col_1 + 5, 0)");
  16. DataRow row = table.NewRow ();
  17. row ["Col_0.Value"] = 20;
  18. row ["Col_1"] = 10;
  19. table.Rows.Add (row);
  20. Assert.AreEqual ((int)table.Rows[0][1] + 5, table.Rows[0][2], "#1");
  21. }
  22. [Test]
  23. public void TestDataColumnExpr2 ()
  24. {
  25. DataTable table = new DataTable ();
  26. table.Columns.Add ("Col_0.Value", Type.GetType ("System.Int32"));
  27. table.Columns.Add ("Col_1", Type.GetType ("System.Int32"));
  28. table.Columns.Add ("Result", Type.GetType ("System.Int32"), "IIF(Col_0.Value > 10, Col_1 + 5, 0)");
  29. DataRow row = table.NewRow ();
  30. row ["Col_0.Value"] = 9;
  31. row ["Col_1"] = 10;
  32. table.Rows.Add (row);
  33. Assert.AreEqual (0, (int)table.Rows[0][2], "#1");
  34. }
  35. }
  36. }