|
|
@@ -35,14 +35,16 @@
|
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
//
|
|
|
|
|
|
-using NUnit.Framework;
|
|
|
using System;
|
|
|
+using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
|
|
|
+using NUnit.Framework;
|
|
|
+
|
|
|
namespace MonoTests.System.Data
|
|
|
{
|
|
|
[TestFixture]
|
|
|
- public class DataColumnTest : Assertion
|
|
|
+ public class DataColumnTest
|
|
|
{
|
|
|
private DataTable _tbl;
|
|
|
|
|
|
@@ -53,30 +55,31 @@ namespace MonoTests.System.Data
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
- public void Ctor()
|
|
|
+ public void Ctor()
|
|
|
{
|
|
|
string colName = "ColName";
|
|
|
- DataColumn col = new DataColumn();
|
|
|
+ DataColumn col = new DataColumn ();
|
|
|
|
|
|
//These should all ctor without an exception
|
|
|
- col = new DataColumn(colName);
|
|
|
- col = new DataColumn(colName,typeof(int));
|
|
|
- col = new DataColumn(colName,typeof(int),null);
|
|
|
- col = new DataColumn(colName,typeof(int),null,MappingType.Attribute);
|
|
|
-
|
|
|
- //DataType Null
|
|
|
- try
|
|
|
- {
|
|
|
- col = new DataColumn(colName, null);
|
|
|
- Fail("DC7: Failed to throw ArgumentNullException.");
|
|
|
- }
|
|
|
- catch (ArgumentNullException){}
|
|
|
- catch (AssertionException exc) {throw exc;}
|
|
|
- catch (Exception exc)
|
|
|
- {
|
|
|
- Fail("DC8: DataColumnNull. Wrong exception type. Got:" + exc);
|
|
|
- }
|
|
|
+ col = new DataColumn (colName);
|
|
|
+ col = new DataColumn (colName, typeof(int));
|
|
|
+ col = new DataColumn (colName, typeof(int), null);
|
|
|
+ col = new DataColumn (colName, typeof(int), null, MappingType.Attribute);
|
|
|
+ }
|
|
|
|
|
|
+ [Test]
|
|
|
+ public void Constructor3_DataType_Null ()
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ new DataColumn ("ColName", (Type) null);
|
|
|
+ Assert.Fail ("#1");
|
|
|
+ } catch (ArgumentNullException ex) {
|
|
|
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
|
|
|
+ Assert.IsNull (ex.InnerException, "#3");
|
|
|
+ Assert.IsNotNull (ex.Message, "#4");
|
|
|
+ Assert.IsNotNull (ex.ParamName, "#5");
|
|
|
+ Assert.AreEqual ("dataType", ex.ParamName, "#6");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
@@ -88,12 +91,9 @@ namespace MonoTests.System.Data
|
|
|
_tbl.Rows.Add(_tbl.NewRow());
|
|
|
_tbl.Rows[0]["NullCheck"] = DBNull.Value;
|
|
|
try {
|
|
|
- col.AllowDBNull = false;
|
|
|
- Fail("DC8b: Failed to throw DataException.");
|
|
|
- }
|
|
|
- catch (DataException) {}
|
|
|
- catch (Exception exc) {
|
|
|
- Fail("DC8c: Wrong exception type. Got:" + exc);
|
|
|
+ col.AllowDBNull = false;
|
|
|
+ Assert.Fail ("DC8b: Failed to throw DataException.");
|
|
|
+ } catch (DataException) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -117,44 +117,35 @@ namespace MonoTests.System.Data
|
|
|
col.AllowDBNull = true;
|
|
|
col.AllowDBNull = false;
|
|
|
|
|
|
- AssertEquals (false, col.AllowDBNull);
|
|
|
+ Assert.IsFalse (col.AllowDBNull);
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
public void AutoIncrement()
|
|
|
{
|
|
|
- DataColumn col = new DataColumn("Auto",typeof(string));
|
|
|
+ DataColumn col = new DataColumn("Auto",typeof (string));
|
|
|
col.AutoIncrement = true;
|
|
|
|
|
|
//Check for Correct Default Values
|
|
|
- AssertEquals("DC9: Seed default", (long)0, col.AutoIncrementSeed);
|
|
|
- AssertEquals("DC10: Step default", (long)1, col.AutoIncrementStep);
|
|
|
+ Assert.AreEqual (0L, col.AutoIncrementSeed, "#1");
|
|
|
+ Assert.AreEqual (1L, col.AutoIncrementStep, "#2");
|
|
|
|
|
|
//Check for auto type convert
|
|
|
- Assert("DC11: AutoInc type convert failed." ,col.DataType == typeof (int));
|
|
|
+ Assert.AreEqual (typeof (int), col.DataType, "#3");
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
public void AutoIncrementExceptions()
|
|
|
{
|
|
|
DataColumn col = new DataColumn();
|
|
|
-
|
|
|
col.Expression = "SomeExpression";
|
|
|
|
|
|
//if computed column exception is thrown
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
col.AutoIncrement = true;
|
|
|
- Fail("DC12: Failed to throw ArgumentException");
|
|
|
- }
|
|
|
- catch (ArgumentException){}
|
|
|
- catch (AssertionException exc) {throw exc;}
|
|
|
- catch (Exception exc)
|
|
|
- {
|
|
|
- Fail("DC13: ExprAutoInc. Wrong exception type. Got:" + exc);
|
|
|
+ Assert.Fail ("DC12: Failed to throw ArgumentException");
|
|
|
+ } catch (ArgumentException) {
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
@@ -162,17 +153,66 @@ namespace MonoTests.System.Data
|
|
|
{
|
|
|
DataColumn col = new DataColumn("ColName");
|
|
|
//Caption not set at this point
|
|
|
- AssertEquals("DC14: Caption Should Equal Col Name", col.ColumnName, col.Caption);
|
|
|
+ Assert.AreEqual (col.ColumnName, col.Caption, "#1");
|
|
|
|
|
|
//Set caption
|
|
|
col.Caption = "MyCaption";
|
|
|
- AssertEquals("DC15: Caption should equal caption.", "MyCaption", col.Caption);
|
|
|
+ Assert.AreEqual ("MyCaption", col.Caption, "#2");
|
|
|
|
|
|
//Clear caption
|
|
|
col.Caption = null;
|
|
|
- AssertEquals("DC16: Caption Should Equal empty string after clear", String.Empty, col.Caption);
|
|
|
-
|
|
|
+ Assert.AreEqual (string.Empty, col.Caption, "#3");
|
|
|
+ }
|
|
|
+
|
|
|
+#if NET_2_0
|
|
|
+ [Test]
|
|
|
+ public void DateTimeMode_Valid ()
|
|
|
+ {
|
|
|
+ DataColumn col = new DataColumn ("birthdate", typeof (DateTime));
|
|
|
+ col.DateTimeMode = DataSetDateTime.Local;
|
|
|
+ Assert.AreEqual (DataSetDateTime.Local, col.DateTimeMode, "#1");
|
|
|
+ col.DateTimeMode = DataSetDateTime.Unspecified;
|
|
|
+ Assert.AreEqual (DataSetDateTime.Unspecified, col.DateTimeMode, "#2");
|
|
|
+ col.DateTimeMode = DataSetDateTime.Utc;
|
|
|
+ Assert.AreEqual (DataSetDateTime.Utc, col.DateTimeMode, "#3");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void DateTime_DataType_Invalid ()
|
|
|
+ {
|
|
|
+ DataColumn col = new DataColumn ("birthdate", typeof (int));
|
|
|
+ try {
|
|
|
+ col.DateTimeMode = DataSetDateTime.Local;
|
|
|
+ Assert.Fail ("#1");
|
|
|
+ } catch (InvalidOperationException ex) {
|
|
|
+ // The DateTimeMode can be set only on DataColumns
|
|
|
+ // of type DateTime
|
|
|
+ Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
|
|
|
+ Assert.IsNull (ex.InnerException, "#3");
|
|
|
+ Assert.IsNotNull (ex.Message, "#4");
|
|
|
+ Assert.IsTrue (ex.Message.IndexOf ("DateTimeMode") != -1, "#5");
|
|
|
+ Assert.IsTrue (ex.Message.IndexOf ("DateTime") != -1, "#6");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void DateTimeMode_Invalid ()
|
|
|
+ {
|
|
|
+ DataColumn col = new DataColumn ("birthdate", typeof (DateTime));
|
|
|
+ try {
|
|
|
+ col.DateTimeMode = (DataSetDateTime) 666;
|
|
|
+ Assert.Fail ("#1");
|
|
|
+ } catch (InvalidEnumArgumentException ex) {
|
|
|
+ // The DataSetDateTime enumeration value, 666, is invalid
|
|
|
+ Assert.AreEqual (typeof (InvalidEnumArgumentException), ex.GetType (), "#2");
|
|
|
+ Assert.IsNull (ex.InnerException, "#3");
|
|
|
+ Assert.IsNotNull (ex.Message, "#4");
|
|
|
+ Assert.IsTrue (ex.Message.IndexOf ("DataSetDateTime") != -1, "#5");
|
|
|
+ Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#6");
|
|
|
+ Assert.IsNull (ex.ParamName, "#7");
|
|
|
+ }
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
[Test]
|
|
|
public void ForColumnNameException()
|
|
|
@@ -183,25 +223,18 @@ namespace MonoTests.System.Data
|
|
|
DataColumn col4 = new DataColumn();
|
|
|
|
|
|
col.ColumnName = "abc";
|
|
|
- AssertEquals( "abc", col.ColumnName);
|
|
|
+ Assert.AreEqual ("abc", col.ColumnName, "#1");
|
|
|
|
|
|
_tbl.Columns.Add(col);
|
|
|
|
|
|
//Duplicate name exception
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
col2.ColumnName = "abc";
|
|
|
_tbl.Columns.Add(col2);
|
|
|
- AssertEquals( "abc", col2.ColumnName);
|
|
|
- Fail("DC17: Failed to throw duplicate name exception.");
|
|
|
+ Assert.AreEqual ("abc", col2.ColumnName, "#2");
|
|
|
+ Assert.Fail ("#3");
|
|
|
+ } catch (DuplicateNameException) {
|
|
|
}
|
|
|
- catch (DuplicateNameException){}
|
|
|
- catch (AssertionException exc) {throw exc;}
|
|
|
- catch (Exception exc)
|
|
|
- {
|
|
|
- Fail("DC18: Wrong exception type. " + exc.ToString());
|
|
|
- }
|
|
|
-
|
|
|
// Make sure case matters in duplicate checks
|
|
|
col3.ColumnName = "ABC";
|
|
|
_tbl.Columns.Add(col3);
|
|
|
@@ -215,138 +248,107 @@ namespace MonoTests.System.Data
|
|
|
|
|
|
//Set default Value if Autoincrement is true
|
|
|
tbl.Columns[0].AutoIncrement = true;
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
tbl.Columns[0].DefaultValue = 2;
|
|
|
- Fail("DC19: Failed to throw ArgumentException.");
|
|
|
- }
|
|
|
- catch (ArgumentException){}
|
|
|
- catch (AssertionException exc) {throw exc;}
|
|
|
- catch (Exception exc)
|
|
|
- {
|
|
|
- Fail("DC20: Wrong exception type. " + exc.ToString());
|
|
|
+ Assert.Fail ("DC19: Failed to throw ArgumentException.");
|
|
|
+ } catch (ArgumentException) {
|
|
|
}
|
|
|
|
|
|
-
|
|
|
tbl.Columns[0].AutoIncrement = false;
|
|
|
|
|
|
//Set default value to an incompatible datatype
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
tbl.Columns[0].DefaultValue = "hello";
|
|
|
- Fail("DC21: Failed to throw FormatException.");
|
|
|
- }
|
|
|
- catch (FormatException){}
|
|
|
- catch (AssertionException exc) {throw exc;}
|
|
|
- catch (Exception exc)
|
|
|
- {
|
|
|
- Fail("DC22: Wrong exception type. " + exc.ToString());
|
|
|
+ Assert.Fail ("DC21: Failed to throw FormatException.");
|
|
|
+ } catch (FormatException) {
|
|
|
}
|
|
|
|
|
|
//TODO: maybe add tests for setting default value for types that can implict
|
|
|
//cast
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
- public void SetDataType()
|
|
|
+ public void SetDataType ()
|
|
|
{
|
|
|
//test for DataAlready exists and change the datatype
|
|
|
-
|
|
|
//supported datatype
|
|
|
-
|
|
|
//AutoInc column dataType supported
|
|
|
-
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
- public void Defaults1()
|
|
|
+ public void Defaults1 ()
|
|
|
{
|
|
|
//Check for defaults - ColumnName not set at the beginning
|
|
|
- DataTable table = new DataTable();
|
|
|
+ DataTable table = new DataTable();
|
|
|
DataColumn column = new DataColumn();
|
|
|
-
|
|
|
- AssertEquals("DC1: ColumnName default Before Add", column.ColumnName, String.Empty);
|
|
|
- AssertEquals("DC2: DataType default Before Add", column.DataType.ToString(), typeof(string).ToString());
|
|
|
+
|
|
|
+ Assert.AreEqual (String.Empty, column.ColumnName, "#A1");
|
|
|
+ Assert.AreEqual (typeof (string), column.DataType, "#A2");
|
|
|
|
|
|
table.Columns.Add(column);
|
|
|
-
|
|
|
- AssertEquals("DC3: ColumnName default After Add", table.Columns[0].ColumnName, "Column1");
|
|
|
- AssertEquals("DC4: DataType default After Add", table.Columns[0].DataType.ToString(), typeof(string).ToString());
|
|
|
+
|
|
|
+ Assert.AreEqual ("Column1", table.Columns [0].ColumnName, "#B1");
|
|
|
+ Assert.AreEqual (typeof (string), table.Columns [0].DataType, "#B2");
|
|
|
|
|
|
DataRow row = table.NewRow();
|
|
|
table.Rows.Add(row);
|
|
|
DataRow dataRow = table.Rows[0];
|
|
|
|
|
|
- object v = null;
|
|
|
- try {
|
|
|
- v = dataRow.ItemArray[0];
|
|
|
- }
|
|
|
- catch(Exception e) {
|
|
|
- Fail("DC5: getting item from dataRow.ItemArray[0] threw Exception: " + e);
|
|
|
- }
|
|
|
-
|
|
|
- Type vType = dataRow.ItemArray[0].GetType();
|
|
|
- AssertEquals("DC6: Value from DataRow.Item", v, DBNull.Value);
|
|
|
+ object v = dataRow.ItemArray [0];
|
|
|
+ Assert.AreEqual (typeof (DBNull), v.GetType (), "#C1");
|
|
|
+ Assert.AreEqual (DBNull.Value, v, "#C2");
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
- public void Defaults2()
|
|
|
+ public void Defaults2 ()
|
|
|
{
|
|
|
//Check for defaults - ColumnName set at the beginning
|
|
|
string blah = "Blah";
|
|
|
//Check for defaults - ColumnName not set at the beginning
|
|
|
- DataTable table = new DataTable();
|
|
|
+ DataTable table = new DataTable();
|
|
|
DataColumn column = new DataColumn(blah);
|
|
|
-
|
|
|
- AssertEquals("DC23: ColumnName default Before Add", column.ColumnName,blah);
|
|
|
- AssertEquals("DC24: DataType default Before Add", column.DataType.ToString(), typeof(string).ToString());
|
|
|
+
|
|
|
+ Assert.AreEqual (blah, column.ColumnName, "#A1");
|
|
|
+ Assert.AreEqual (typeof (string), column.DataType, "#A2");
|
|
|
|
|
|
table.Columns.Add(column);
|
|
|
|
|
|
- AssertEquals("DC25: ColumnName default After Add", table.Columns[0].ColumnName, blah);
|
|
|
- AssertEquals("DC26: DataType default After Add", table.Columns[0].DataType.ToString(), typeof(string).ToString());
|
|
|
+ Assert.AreEqual (blah, table.Columns[0].ColumnName, "#B1");
|
|
|
+ Assert.AreEqual (typeof (string), table.Columns[0].DataType, "#B2");
|
|
|
|
|
|
DataRow row = table.NewRow();
|
|
|
table.Rows.Add(row);
|
|
|
DataRow dataRow = table.Rows[0];
|
|
|
|
|
|
- object v = null;
|
|
|
- try {
|
|
|
- v = dataRow.ItemArray[0];
|
|
|
- }
|
|
|
- catch(Exception e) {
|
|
|
- Fail("DC27: getting item from dataRow.ItemArray[0] threw Exception: " + e);
|
|
|
- }
|
|
|
-
|
|
|
- Type vType = dataRow.ItemArray[0].GetType();
|
|
|
- AssertEquals("DC28: Value from DataRow.Item", v, DBNull.Value);
|
|
|
+ object v = dataRow.ItemArray[0];
|
|
|
+ Assert.AreEqual (typeof (DBNull), v.GetType (), "#C1");
|
|
|
+ Assert.AreEqual (DBNull.Value, v, "#C2");
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
- [ExpectedException (typeof (OverflowException))]
|
|
|
- public void ExpressionSubstringlimits() {
|
|
|
- DataTable t = new DataTable();
|
|
|
- t.Columns.Add("aaa");
|
|
|
- t.Rows.Add(new object[]{"xxx"});
|
|
|
- DataColumn c = t.Columns.Add("bbb");
|
|
|
- c.Expression= "SUBSTRING(aaa, 6000000000000000, 2)";
|
|
|
+ public void ExpressionSubstringlimits () {
|
|
|
+ DataTable t = new DataTable ();
|
|
|
+ t.Columns.Add ("aaa");
|
|
|
+ t.Rows.Add (new object [] {"xxx"});
|
|
|
+ DataColumn c = t.Columns.Add ("bbb");
|
|
|
+ try {
|
|
|
+ c.Expression = "SUBSTRING(aaa, 6000000000000000, 2)";
|
|
|
+ Assert.Fail ("#1");
|
|
|
+ } catch (OverflowException) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
- public void ExpressionFunctions ()
|
|
|
- {
|
|
|
- DataTable T = new DataTable ("test");
|
|
|
+ public void ExpressionFunctions ()
|
|
|
+ {
|
|
|
+ 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");
|
|
|
- C.Expression = "substring (name, 1, 3) + len (name) + age";
|
|
|
+ C.Expression = "substring (name, 1, 3) + len (name) + age";
|
|
|
T.Columns.Add (C);
|
|
|
|
|
|
DataSet Set = new DataSet ("TestSet");
|
|
|
@@ -364,71 +366,67 @@ namespace MonoTests.System.Data
|
|
|
Row [0] = "h*an";
|
|
|
Row [1] = DBNull.Value;
|
|
|
T.Rows.Add (Row);
|
|
|
-
|
|
|
- AssertEquals ("DC29", "hum710", T.Rows [10] [2]);
|
|
|
- AssertEquals ("DC30", "hum64", T.Rows [4] [2]);
|
|
|
- C = T.Columns [2];
|
|
|
- C.Expression = "isnull (age, 'succ[[]]ess')";
|
|
|
- AssertEquals ("DC31", "succ[[]]ess", T.Rows [100] [2]);
|
|
|
-
|
|
|
- C.Expression = "iif (age = 24, 'hurrey', 'boo')";
|
|
|
- AssertEquals ("DC32", "boo", T.Rows [50] [2]);
|
|
|
- AssertEquals ("DC33", "hurrey", T.Rows [24] [2]);
|
|
|
-
|
|
|
- C.Expression = "convert (age, 'System.Boolean')";
|
|
|
- AssertEquals ("DC32", Boolean.TrueString, T.Rows [50] [2]);
|
|
|
- AssertEquals ("DC32", Boolean.FalseString, T.Rows [0] [2]);
|
|
|
-
|
|
|
- //
|
|
|
- // Exceptions
|
|
|
- //
|
|
|
-
|
|
|
- try {
|
|
|
- C.Expression = "iff (age = 24, 'hurrey', 'boo')";
|
|
|
-
|
|
|
- // The expression contains undefined function call iff().
|
|
|
- Fail ("DC34");
|
|
|
+
|
|
|
+ Assert.AreEqual ("hum710", T.Rows [10] [2], "#A1");
|
|
|
+ Assert.AreEqual ("hum64", T.Rows [4] [2], "#A2");
|
|
|
+ C = T.Columns [2];
|
|
|
+ C.Expression = "isnull (age, 'succ[[]]ess')";
|
|
|
+ Assert.AreEqual ("succ[[]]ess", T.Rows [100] [2], "#A3");
|
|
|
+
|
|
|
+ C.Expression = "iif (age = 24, 'hurrey', 'boo')";
|
|
|
+ Assert.AreEqual ("boo", T.Rows [50] [2], "#B1");
|
|
|
+ Assert.AreEqual ("hurrey", T.Rows [24] [2], "#B2");
|
|
|
+
|
|
|
+ C.Expression = "convert (age, 'System.Boolean')";
|
|
|
+ Assert.AreEqual (Boolean.TrueString, T.Rows [50] [2], "#C1");
|
|
|
+ Assert.AreEqual (Boolean.FalseString, T.Rows [0] [2], "#C2");
|
|
|
+
|
|
|
+ //
|
|
|
+ // Exceptions
|
|
|
+ //
|
|
|
+
|
|
|
+ try {
|
|
|
+ // The expression contains undefined function call iff().
|
|
|
+ C.Expression = "iff (age = 24, 'hurrey', 'boo')";
|
|
|
+ Assert.Fail ("#D");
|
|
|
} catch (EvaluateException) {
|
|
|
} catch (SyntaxErrorException) {
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //The following two cases fail on mono. MS.net evaluates the expression
|
|
|
- //immediatly upon assignment. We don't do this yet hence we don't throw
|
|
|
- //an exception at this point.
|
|
|
- try {
|
|
|
- C.Expression = "iif (nimi = 24, 'hurrey', 'boo')";
|
|
|
- Fail ("DC36");
|
|
|
- } catch (EvaluateException e) {
|
|
|
- AssertEquals ("DC37", typeof (EvaluateException), e.GetType ());
|
|
|
- AssertEquals ("DC38", "Cannot find column [nimi].", e.Message);
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- C.Expression = "iif (name = 24, 'hurrey', 'boo')";
|
|
|
- Fail ("DC39");
|
|
|
- } catch (Exception e) {
|
|
|
- AssertEquals ("DC40", typeof (EvaluateException), e.GetType ());
|
|
|
- //AssertEquals ("DC41", "Cannot perform '=' operation on System.String and System.Int32.", e.Message);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- try {
|
|
|
- C.Expression = "convert (age, Boolean)";
|
|
|
- Fail ("DC42");
|
|
|
- } catch (Exception e) {
|
|
|
- AssertEquals ("DC43", typeof (EvaluateException), e.GetType ());
|
|
|
- AssertEquals ("DC44", "Invalid type name 'Boolean'.", e.Message);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ //The following two cases fail on mono. MS.net evaluates the expression
|
|
|
+ //immediatly upon assignment. We don't do this yet hence we don't throw
|
|
|
+ //an exception at this point.
|
|
|
+ try {
|
|
|
+ C.Expression = "iif (nimi = 24, 'hurrey', 'boo')";
|
|
|
+ Assert.Fail ("#E1");
|
|
|
+ } catch (EvaluateException e) {
|
|
|
+ Assert.AreEqual (typeof (EvaluateException), e.GetType (), "#E2");
|
|
|
+ Assert.AreEqual ("Cannot find column [nimi].", e.Message, "#E3");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ C.Expression = "iif (name = 24, 'hurrey', 'boo')";
|
|
|
+ Assert.Fail ("#F1");
|
|
|
+ } catch (EvaluateException e) {
|
|
|
+ Assert.AreEqual (typeof (EvaluateException), e.GetType (), "#F2");
|
|
|
+ //AssertEquals ("DC41", "Cannot perform '=' operation on System.String and System.Int32.", e.Message);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ C.Expression = "convert (age, Boolean)";
|
|
|
+ Assert.Fail ("#G1");
|
|
|
+ } catch (EvaluateException e) {
|
|
|
+ Assert.AreEqual (typeof (EvaluateException), e.GetType (), "#G2");
|
|
|
+ Assert.AreEqual ("Invalid type name 'Boolean'.", e.Message, "#G3");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
[Test]
|
|
|
- public void ExpressionAggregates ()
|
|
|
- {
|
|
|
- DataTable T = new DataTable ("test");
|
|
|
+ public void ExpressionAggregates ()
|
|
|
+ {
|
|
|
+ DataTable T = new DataTable ("test");
|
|
|
DataTable T2 = new DataTable ("test2");
|
|
|
-
|
|
|
+
|
|
|
DataColumn C = new DataColumn ("name");
|
|
|
T.Columns.Add (C);
|
|
|
C = new DataColumn ("age");
|
|
|
@@ -436,7 +434,7 @@ namespace MonoTests.System.Data
|
|
|
T.Columns.Add (C);
|
|
|
C = new DataColumn ("childname");
|
|
|
T.Columns.Add (C);
|
|
|
-
|
|
|
+
|
|
|
C = new DataColumn ("expression");
|
|
|
T.Columns.Add (C);
|
|
|
|
|
|
@@ -459,11 +457,11 @@ namespace MonoTests.System.Data
|
|
|
T.Rows.Add (Row);
|
|
|
|
|
|
C = new DataColumn ("name");
|
|
|
- T2.Columns.Add (C);
|
|
|
+ T2.Columns.Add (C);
|
|
|
C = new DataColumn ("age");
|
|
|
C.DataType = typeof (int);
|
|
|
T2.Columns.Add (C);
|
|
|
-
|
|
|
+
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
Row = T2.NewRow ();
|
|
|
Row [0] = "child" + i;
|
|
|
@@ -474,51 +472,51 @@ namespace MonoTests.System.Data
|
|
|
Row [1] = i - 2;
|
|
|
T2.Rows.Add (Row);
|
|
|
}
|
|
|
-
|
|
|
- DataRelation Rel = new DataRelation ("Rel", T.Columns [2], T2.Columns [0]);
|
|
|
- Set.Relations.Add (Rel);
|
|
|
-
|
|
|
- C = T.Columns [3];
|
|
|
- C.Expression = "Sum (Child.age)";
|
|
|
- AssertEquals ("DC45", "-2", T.Rows [0] [3]);
|
|
|
- AssertEquals ("DC46", "98", T.Rows [50] [3]);
|
|
|
-
|
|
|
+
|
|
|
+ DataRelation Rel = new DataRelation ("Rel", T.Columns [2], T2.Columns [0]);
|
|
|
+ Set.Relations.Add (Rel);
|
|
|
+
|
|
|
+ C = T.Columns [3];
|
|
|
+ C.Expression = "Sum (Child.age)";
|
|
|
+ Assert.AreEqual ("-2", T.Rows [0] [3], "#A1");
|
|
|
+ Assert.AreEqual ("98", T.Rows [50] [3], "#A2");
|
|
|
+
|
|
|
C.Expression = "Count (Child.age)";
|
|
|
- AssertEquals ("DC47", "2", T.Rows [0] [3]);
|
|
|
- AssertEquals ("DC48", "2", T.Rows [60] [3]);
|
|
|
+ Assert.AreEqual ("2", T.Rows [0] [3], "#B1");
|
|
|
+ Assert.AreEqual ("2", T.Rows [60] [3], "#B2");
|
|
|
|
|
|
C.Expression = "Avg (Child.age)";
|
|
|
- AssertEquals ("DC49", "-1", T.Rows [0] [3]);
|
|
|
- AssertEquals ("DC50", "59", T.Rows [60] [3]);
|
|
|
+ Assert.AreEqual ("-1", T.Rows [0] [3], "#C1");
|
|
|
+ Assert.AreEqual ("59", T.Rows [60] [3], "#C2");
|
|
|
|
|
|
C.Expression = "Min (Child.age)";
|
|
|
- AssertEquals ("DC51", "-2", T.Rows [0] [3]);
|
|
|
- AssertEquals ("DC52", "58", T.Rows [60] [3]);
|
|
|
+ Assert.AreEqual ("-2", T.Rows [0] [3], "#D1");
|
|
|
+ Assert.AreEqual ("58", T.Rows [60] [3], "#D2");
|
|
|
|
|
|
C.Expression = "Max (Child.age)";
|
|
|
- AssertEquals ("DC53", "0", T.Rows [0] [3]);
|
|
|
- AssertEquals ("DC54", "60", T.Rows [60] [3]);
|
|
|
+ Assert.AreEqual ("0", T.Rows [0] [3], "#E1");
|
|
|
+ Assert.AreEqual ("60", T.Rows [60] [3], "#E2");
|
|
|
|
|
|
C.Expression = "stdev (Child.age)";
|
|
|
- AssertEquals ("DC55", (1.4142135623731).ToString(), T.Rows [0] [3]);
|
|
|
- AssertEquals ("DC56", (1.4142135623731).ToString(), T.Rows [60] [3]);
|
|
|
+ Assert.AreEqual ((1.4142135623731).ToString (), T.Rows [0] [3], "#F1");
|
|
|
+ Assert.AreEqual ((1.4142135623731).ToString (), T.Rows [60] [3], "#F2");
|
|
|
|
|
|
C.Expression = "var (Child.age)";
|
|
|
- AssertEquals ("DC57", "2", T.Rows [0] [3]);
|
|
|
- AssertEquals ("DC58", "2", T.Rows [60] [3]);
|
|
|
- }
|
|
|
+ Assert.AreEqual ("2", T.Rows [0] [3], "#G1");
|
|
|
+ Assert.AreEqual ("2", T.Rows [60] [3], "#G2");
|
|
|
+ }
|
|
|
|
|
|
[Test]
|
|
|
public void ExpressionOperator ()
|
|
|
{
|
|
|
- DataTable T = new DataTable ("test");
|
|
|
+ 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");
|
|
|
- C.Expression = "substring (name, 1, 3) + len (name) + age";
|
|
|
+ C.Expression = "substring (name, 1, 3) + len (name) + age";
|
|
|
T.Columns.Add (C);
|
|
|
|
|
|
DataSet Set = new DataSet ("TestSet");
|
|
|
@@ -537,57 +535,56 @@ namespace MonoTests.System.Data
|
|
|
Row [1] = DBNull.Value;
|
|
|
T.Rows.Add (Row);
|
|
|
|
|
|
- C = T.Columns [2];
|
|
|
- C.Expression = "age + 4";
|
|
|
- AssertEquals ("DC59", "68", T.Rows [64] [2]);
|
|
|
+ C = T.Columns [2];
|
|
|
+ C.Expression = "age + 4";
|
|
|
+ Assert.AreEqual ("68", T.Rows [64] [2], "#A");
|
|
|
|
|
|
C.Expression = "age - 4";
|
|
|
- AssertEquals ("DC60", "60", T.Rows [64] [2]);
|
|
|
+ Assert.AreEqual ("60", T.Rows [64] [2], "#B");
|
|
|
|
|
|
C.Expression = "age * 4";
|
|
|
- AssertEquals ("DC61", "256", T.Rows [64] [2]);
|
|
|
+ Assert.AreEqual ("256", T.Rows [64] [2], "#C");
|
|
|
|
|
|
C.Expression = "age / 4";
|
|
|
- AssertEquals ("DC62", "16", T.Rows [64] [2]);
|
|
|
+ Assert.AreEqual ("16", T.Rows [64] [2], "#D");
|
|
|
|
|
|
C.Expression = "age % 5";
|
|
|
- AssertEquals ("DC63", "4", T.Rows [64] [2]);
|
|
|
+ Assert.AreEqual ("4", T.Rows [64] [2], "#E");
|
|
|
|
|
|
C.Expression = "age in (5, 10, 15, 20, 25)";
|
|
|
- AssertEquals ("DC64", "False", T.Rows [64] [2]);
|
|
|
- AssertEquals ("DC65", "True", T.Rows [25] [2]);
|
|
|
+ Assert.AreEqual ("False", T.Rows [64] [2], "#F1");
|
|
|
+ Assert.AreEqual ("True", T.Rows [25] [2], "#F2");
|
|
|
|
|
|
C.Expression = "name like 'human1%'";
|
|
|
- AssertEquals ("DC66", "True", T.Rows [1] [2]);
|
|
|
- AssertEquals ("DC67", "False", T.Rows [25] [2]);
|
|
|
+ Assert.AreEqual ("True", T.Rows [1] [2], "#G1");
|
|
|
+ Assert.AreEqual ("False", T.Rows [25] [2], "#G2");
|
|
|
|
|
|
- C.Expression = "age < 4";
|
|
|
- AssertEquals ("DC68", "False", T.Rows [4] [2]);
|
|
|
- AssertEquals ("DC69", "True", T.Rows [3] [2]);
|
|
|
+ C.Expression = "age < 4";
|
|
|
+ Assert.AreEqual ("False", T.Rows [4] [2], "#H1");
|
|
|
+ Assert.AreEqual ("True", T.Rows [3] [2], "#H2");
|
|
|
|
|
|
- C.Expression = "age <= 4";
|
|
|
- AssertEquals ("DC70", "True", T.Rows [4] [2]);
|
|
|
- AssertEquals ("DC71", "False", T.Rows [5] [2]);
|
|
|
+ C.Expression = "age <= 4";
|
|
|
+ Assert.AreEqual ("True", T.Rows [4] [2], "#I1");
|
|
|
+ Assert.AreEqual ("False", T.Rows [5] [2], "#I2");
|
|
|
|
|
|
- C.Expression = "age > 4";
|
|
|
- AssertEquals ("DC72", "False", T.Rows [4] [2]);
|
|
|
- AssertEquals ("DC73", "True", T.Rows [5] [2]);
|
|
|
+ C.Expression = "age > 4";
|
|
|
+ Assert.AreEqual ("False", T.Rows [4] [2], "#J1");
|
|
|
+ Assert.AreEqual ("True", T.Rows [5] [2], "#J2");
|
|
|
|
|
|
- C.Expression = "age >= 4";
|
|
|
- AssertEquals ("DC74", "True", T.Rows [4] [2]);
|
|
|
- AssertEquals ("DC75", "False", T.Rows [1] [2]);
|
|
|
+ C.Expression = "age >= 4";
|
|
|
+ Assert.AreEqual ("True", T.Rows [4] [2], "#K1");
|
|
|
+ Assert.AreEqual ("False", T.Rows [1] [2], "#K2");
|
|
|
|
|
|
- C.Expression = "age = 4";
|
|
|
- AssertEquals ("DC76", "True", T.Rows [4] [2]);
|
|
|
- AssertEquals ("DC77", "False", T.Rows [1] [2]);
|
|
|
+ C.Expression = "age = 4";
|
|
|
+ Assert.AreEqual ("True", T.Rows [4] [2], "#L1");
|
|
|
+ Assert.AreEqual ("False", T.Rows [1] [2], "#L2");
|
|
|
|
|
|
- C.Expression = "age <> 4";
|
|
|
- AssertEquals ("DC76", "False", T.Rows [4] [2]);
|
|
|
- AssertEquals ("DC77", "True", T.Rows [1] [2]);
|
|
|
+ C.Expression = "age <> 4";
|
|
|
+ Assert.AreEqual ("False", T.Rows [4] [2], "#M1");
|
|
|
+ Assert.AreEqual ("True", T.Rows [1] [2], "#M2");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
[Test]
|
|
|
- [ExpectedException (typeof (ArgumentException))]
|
|
|
public void SetMaxLengthException ()
|
|
|
{
|
|
|
// Setting MaxLength on SimpleContent -> exception
|
|
|
@@ -595,7 +592,11 @@ namespace MonoTests.System.Data
|
|
|
ds.Tables.Add("MyType");
|
|
|
ds.Tables["MyType"].Columns.Add(new DataColumn("Desc",
|
|
|
typeof (string), "", MappingType.SimpleContent));
|
|
|
- ds.Tables["MyType"].Columns["Desc"].MaxLength = 32;
|
|
|
+ try {
|
|
|
+ ds.Tables ["MyType"].Columns ["Desc"].MaxLength = 32;
|
|
|
+ Assert.Fail ("#1");
|
|
|
+ } catch (ArgumentException) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
@@ -610,21 +611,19 @@ namespace MonoTests.System.Data
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
- public void AdditionToConstraintCollectionTest()
|
|
|
- {
|
|
|
- DataTable myTable = new DataTable("myTable");
|
|
|
- DataColumn idCol = new DataColumn("id",Type.GetType("System.Int32")); //set the unique property and add them to the table
|
|
|
- idCol.Unique=true;
|
|
|
- myTable.Columns.Add(idCol);
|
|
|
- ConstraintCollection cc = myTable.Constraints;
|
|
|
- //cc just contains a single UniqueConstraint object.
|
|
|
- UniqueConstraint uc = cc[0] as UniqueConstraint;
|
|
|
- AssertEquals("#verifying whether the column associated with the UniqueConstraint is same:", uc.Columns[0].ColumnName , "id");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // Testcase for #77025
|
|
|
- [Test]
|
|
|
+ public void AdditionToConstraintCollectionTest()
|
|
|
+ {
|
|
|
+ DataTable myTable = new DataTable("myTable");
|
|
|
+ DataColumn idCol = new DataColumn("id", typeof (int));
|
|
|
+ idCol.Unique = true;
|
|
|
+ myTable.Columns.Add(idCol);
|
|
|
+ ConstraintCollection cc = myTable.Constraints;
|
|
|
+ //cc just contains a single UniqueConstraint object.
|
|
|
+ UniqueConstraint uc = cc[0] as UniqueConstraint;
|
|
|
+ Assert.AreEqual ("id", uc.Columns[0].ColumnName);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test] // bug #77025
|
|
|
public void CalcStatisticalFunction_SingleElement()
|
|
|
{
|
|
|
DataTable table = new DataTable ();
|
|
|
@@ -635,8 +634,8 @@ namespace MonoTests.System.Data
|
|
|
table.Columns.Add ("result_stdev", typeof (double), "stdev(test)");
|
|
|
|
|
|
// Check DBNull.Value is set as the result
|
|
|
- AssertEquals ("#1" , typeof (DBNull), (table.Rows[0]["result_var"]).GetType ());
|
|
|
- AssertEquals ("#2" , typeof (DBNull), (table.Rows[0]["result_stdev"]).GetType ());
|
|
|
+ Assert.AreEqual (typeof (DBNull), (table.Rows[0]["result_var"]).GetType (), "#1");
|
|
|
+ Assert.AreEqual (typeof (DBNull), (table.Rows [0] ["result_stdev"]).GetType (), "#2");
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
@@ -655,25 +654,25 @@ namespace MonoTests.System.Data
|
|
|
|
|
|
// Adding the rows after all the expression columns are added
|
|
|
table.Rows.Add (new object[] {0});
|
|
|
- AssertEquals ("#1", 1, table.Rows[0]["result_count"]);
|
|
|
- AssertEquals ("#2", 0, table.Rows[0]["result_sum"]);
|
|
|
- AssertEquals ("#3", 0, table.Rows[0]["result_avg"]);
|
|
|
- AssertEquals ("#4", 0, table.Rows[0]["result_max"]);
|
|
|
- AssertEquals ("#5", 0, table.Rows[0]["result_min"]);
|
|
|
- AssertEquals ("#6", DBNull.Value, table.Rows[0]["result_var"]);
|
|
|
- AssertEquals ("#7", DBNull.Value, table.Rows[0]["result_stdev"]);
|
|
|
+ Assert.AreEqual (1, table.Rows [0] ["result_count"], "#A1");
|
|
|
+ Assert.AreEqual (0, table.Rows [0] ["result_sum"], "#A2");
|
|
|
+ Assert.AreEqual (0, table.Rows [0] ["result_avg"], "#A3");
|
|
|
+ Assert.AreEqual (0, table.Rows [0] ["result_max"], "#A4");
|
|
|
+ Assert.AreEqual (0, table.Rows [0] ["result_min"], "#A5");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [0] ["result_var"], "#A6");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [0] ["result_stdev"], "#A7");
|
|
|
|
|
|
table.Rows.Add (new object[] {1});
|
|
|
table.Rows.Add (new object[] {-2});
|
|
|
|
|
|
// Check if the aggregate columns are updated correctly
|
|
|
- AssertEquals ("#8", 3, table.Rows[0]["result_count"]);
|
|
|
- AssertEquals ("#9", -1, table.Rows[0]["result_sum"]);
|
|
|
- AssertEquals ("#10", 0, table.Rows[0]["result_avg"]);
|
|
|
- AssertEquals ("#11", 1, table.Rows[0]["result_max"]);
|
|
|
- AssertEquals ("#12", -2, table.Rows[0]["result_min"]);
|
|
|
- AssertEquals ("#13", (7.0/3), table.Rows[0]["result_var"]);
|
|
|
- AssertEquals ("#14", Math.Sqrt(7.0/3), table.Rows[0]["result_stdev"]);
|
|
|
+ Assert.AreEqual (3, table.Rows [0] ["result_count"], "#B1");
|
|
|
+ Assert.AreEqual (-1, table.Rows [0] ["result_sum"], "#B2");
|
|
|
+ Assert.AreEqual (0, table.Rows [0] ["result_avg"], "#B3");
|
|
|
+ Assert.AreEqual (1, table.Rows [0] ["result_max"], "#B4");
|
|
|
+ Assert.AreEqual (-2, table.Rows [0] ["result_min"], "#B5");
|
|
|
+ Assert.AreEqual ((7.0 / 3), table.Rows [0] ["result_var"], "#B6");
|
|
|
+ Assert.AreEqual (Math.Sqrt (7.0 / 3), table.Rows [0] ["result_stdev"], "#B7");
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
@@ -707,26 +706,26 @@ namespace MonoTests.System.Data
|
|
|
table2.Rows.Add (new object[] {1,j});
|
|
|
|
|
|
// Check the values for the expression columns in parent table
|
|
|
- AssertEquals ("#1", 10, table.Rows[0]["result_count"]);
|
|
|
- AssertEquals ("#2", 0, table.Rows[1]["result_count"]);
|
|
|
+ Assert.AreEqual (10, table.Rows [0] ["result_count"], "#A1");
|
|
|
+ Assert.AreEqual (0, table.Rows [1] ["result_count"], "#A2");
|
|
|
|
|
|
- AssertEquals ("#3", 10, table.Rows[0]["result_sum"]);
|
|
|
- AssertEquals ("#4", DBNull.Value, table.Rows[1]["result_sum"]);
|
|
|
+ Assert.AreEqual (10, table.Rows [0] ["result_sum"], "#B1");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_sum"], "#B2");
|
|
|
|
|
|
- AssertEquals ("#5", 1, table.Rows[0]["result_avg"]);
|
|
|
- AssertEquals ("#6", DBNull.Value, table.Rows[1]["result_avg"]);
|
|
|
+ Assert.AreEqual (1, table.Rows [0] ["result_avg"], "#C1");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_avg"], "#C2");
|
|
|
|
|
|
- AssertEquals ("#7", 1, table.Rows[0]["result_max"]);
|
|
|
- AssertEquals ("#8", DBNull.Value, table.Rows[1]["result_max"]);
|
|
|
+ Assert.AreEqual (1, table.Rows [0] ["result_max"], "#D1");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_max"], "#D2");
|
|
|
|
|
|
- AssertEquals ("#7", 1, table.Rows[0]["result_min"]);
|
|
|
- AssertEquals ("#8", DBNull.Value, table.Rows[1]["result_min"]);
|
|
|
+ Assert.AreEqual (1, table.Rows [0] ["result_min"], "#E1");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_min"], "#E2");
|
|
|
|
|
|
- AssertEquals ("#9", 0, table.Rows[0]["result_var"]);
|
|
|
- AssertEquals ("#10", DBNull.Value, table.Rows[1]["result_var"]);
|
|
|
+ Assert.AreEqual (0, table.Rows [0] ["result_var"], "#F1");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_var"], "#F2");
|
|
|
|
|
|
- AssertEquals ("#11", 0, table.Rows[0]["result_stdev"]);
|
|
|
- AssertEquals ("#12", DBNull.Value, table.Rows[1]["result_stdev"]);
|
|
|
+ Assert.AreEqual (0, table.Rows [0] ["result_stdev"], "#G1");
|
|
|
+ Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_stdev"], "#G2");
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
@@ -754,49 +753,49 @@ namespace MonoTests.System.Data
|
|
|
error = "Aggregation Functions cannot be called on Columns Returning Single Row (Parent Column)";
|
|
|
try {
|
|
|
table2.Columns.Add ("result", typeof (int), "count(parent.test)");
|
|
|
- Fail ("#1" + error);
|
|
|
- }catch (SyntaxErrorException) {
|
|
|
+ Assert.Fail ("#1" + error);
|
|
|
+ } catch (SyntaxErrorException) {
|
|
|
}
|
|
|
|
|
|
error = "Numerical or Functions cannot be called on Columns Returning Multiple Rows (Child Column)";
|
|
|
// Check arithematic operator
|
|
|
try {
|
|
|
table2.Columns.Add ("result", typeof (int), "10*(child.test)");
|
|
|
- Fail ("#2" + error);
|
|
|
- }catch (SyntaxErrorException) {
|
|
|
+ Assert.Fail ("#2" + error);
|
|
|
+ } catch (SyntaxErrorException) {
|
|
|
}
|
|
|
|
|
|
// Check rel operator
|
|
|
try {
|
|
|
table2.Columns.Add ("result", typeof (int), "(child.test) > 10");
|
|
|
- Fail ("#3" + error);
|
|
|
- }catch (SyntaxErrorException) {
|
|
|
+ Assert.Fail ("#3" + error);
|
|
|
+ } catch (SyntaxErrorException) {
|
|
|
}
|
|
|
|
|
|
// Check predicates
|
|
|
try {
|
|
|
table2.Columns.Add ("result", typeof (int), "(child.test) IN (1,2,3)");
|
|
|
- Fail ("#4" + error);
|
|
|
- }catch (SyntaxErrorException) {
|
|
|
+ Assert.Fail ("#4" + error);
|
|
|
+ } catch (SyntaxErrorException) {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
table2.Columns.Add ("result", typeof (int), "(child.test) LIKE 1");
|
|
|
- Fail ("#5" + error);
|
|
|
- }catch (SyntaxErrorException) {
|
|
|
+ Assert.Fail ("#5" + error);
|
|
|
+ } catch (SyntaxErrorException) {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
table2.Columns.Add ("result", typeof (int), "(child.test) IS null");
|
|
|
- Fail ("#6" + error);
|
|
|
- }catch (SyntaxErrorException) {
|
|
|
+ Assert.Fail ("#6" + error);
|
|
|
+ } catch (SyntaxErrorException) {
|
|
|
}
|
|
|
|
|
|
// Check Calc Functions
|
|
|
try {
|
|
|
table2.Columns.Add ("result", typeof (int), "isnull(child.test,10)");
|
|
|
- Fail ("#7" + error);
|
|
|
- }catch (SyntaxErrorException) {
|
|
|
+ Assert.Fail ("#7" + error);
|
|
|
+ } catch (SyntaxErrorException) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -810,8 +809,8 @@ namespace MonoTests.System.Data
|
|
|
table.Rows.Add (new object[] {});
|
|
|
|
|
|
// ms.net behavior.. seems to covert all numbers to double
|
|
|
- AssertEquals ("#1", 1, table.Rows[0][0]);
|
|
|
- AssertEquals ("#2", 1, table.Rows[0][1]);
|
|
|
+ Assert.AreEqual (1, table.Rows [0] [0], "#1");
|
|
|
+ Assert.AreEqual (1, table.Rows [0] [1], "#2");
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
|
@@ -821,21 +820,21 @@ namespace MonoTests.System.Data
|
|
|
DataColumn col1 = new DataColumn ("col1", typeof (int));
|
|
|
DataColumn col2 = new DataColumn ("col2", typeof (int));
|
|
|
|
|
|
- AssertEquals ("#1" , -1, col1.Ordinal);
|
|
|
- AssertEquals ("#2" , null, col1.Table);
|
|
|
+ Assert.AreEqual (-1, col1.Ordinal, "#A1");
|
|
|
+ Assert.IsNull (col1.Table, "#A2");
|
|
|
|
|
|
table.Columns.Add (col1);
|
|
|
table.Columns.Add (col2);
|
|
|
- AssertEquals ("#3" , 0, col1.Ordinal);
|
|
|
- AssertEquals ("#4" , table, col1.Table);
|
|
|
+ Assert.AreEqual (0, col1.Ordinal, "#B1");
|
|
|
+ Assert.AreEqual (table, col1.Table, "#B2");
|
|
|
|
|
|
table.Columns.RemoveAt(0);
|
|
|
- AssertEquals ("#5" , -1, col1.Ordinal);
|
|
|
- AssertEquals ("#6" , null, col1.Table);
|
|
|
+ Assert.AreEqual (-1, col1.Ordinal, "#C1");
|
|
|
+ Assert.IsNull (col1.Table, "#C2");
|
|
|
|
|
|
table.Columns.Clear ();
|
|
|
- AssertEquals ("#7" , -1, col2.Ordinal);
|
|
|
- AssertEquals ("#8" , null, col2.Table);
|
|
|
+ Assert.AreEqual (-1, col2.Ordinal, "#D1");
|
|
|
+ Assert.IsNull (col2.Table, "#D2");
|
|
|
}
|
|
|
}
|
|
|
}
|