[Sys.Data] there are many tests that were unverified on .NET. Fix them.
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 18 Mar 2015 16:54:28 +0000 (00:54 +0800)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 25 Mar 2015 16:25:03 +0000 (01:25 +0900)
20 files changed:
mcs/class/System.Data/Test/Mono.Data.SqlExpressions/DataColumnExpressionTest.cs
mcs/class/System.Data/Test/System.Data.Odbc/OdbcParameterTest.cs
mcs/class/System.Data/Test/System.Data.OleDb/OleDbParameterCollectionTest.cs
mcs/class/System.Data/Test/System.Data.SqlClient/SqlCommandTest.cs
mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest.cs
mcs/class/System.Data/Test/System.Data/DataColumnTest2.cs
mcs/class/System.Data/Test/System.Data/DataRowViewTest2.cs
mcs/class/System.Data/Test/System.Data/DataSetInferXmlSchemaTest.cs
mcs/class/System.Data/Test/System.Data/DataSetReadXmlSchemaTest.cs
mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs
mcs/class/System.Data/Test/System.Data/DataSetTest.cs
mcs/class/System.Data/Test/System.Data/DataTableLoadRowTest.cs
mcs/class/System.Data/Test/System.Data/DataTableReaderTest.cs
mcs/class/System.Data/Test/System.Data/DataTableTest.cs
mcs/class/System.Data/Test/System.Data/DataTableTest3.cs
mcs/class/System.Data/Test/System.Data/DataTableTest4.cs
mcs/class/System.Data/Test/System.Data/DataViewTest.cs
mcs/class/System.Data/Test/System.Data/DataViewTest2.cs
mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest.cs
mcs/class/System.Data/Test/System.Data/UniqueConstraintTest.cs

index 1bd3c4542fa7eca66af8771df31f1bf468376dec..217a30dce28d876cfcf56466daee4d61c5486fc8 100644 (file)
@@ -13,7 +13,7 @@ namespace Monotests_Mono.Data.SqlExpressions
                        DataTable table = new DataTable ();
                        table.Columns.Add ("Col_0.Value", Type.GetType ("System.Int32"));
                        table.Columns.Add ("Col_1", Type.GetType ("System.Int32"));
-                       table.Columns.Add ("Result", Type.GetType ("System.Int32"), "IIF(Col_0.Value, Col_1 + 5, 0)");
+                       table.Columns.Add ("Result", Type.GetType ("System.Int32"), "IIF(Col_0.Value <> 0, Col_1 + 5, 0)");
 
                        DataRow row = table.NewRow ();
                        row ["Col_0.Value"] = 0;
@@ -31,7 +31,7 @@ namespace Monotests_Mono.Data.SqlExpressions
                        dt.Rows.Add (new string [] { null });
                        dt.Rows.Add (new string [] { "xax" });
                        dt.Columns.Add ("c2", typeof (bool), "c1 LIKE '%a%'");
-                       Assert.IsFalse ((bool) dt.Rows [0] [1]);
+                       //Assert.IsFalse ((bool) dt.Rows [0] [1]); ... cannot cast from DBNull to bool.
                        Assert.IsTrue ((bool) dt.Rows [1] [1]);
                }
                
index 2e1b43790fe050a434a7449b53cc6a2f049fffa2..73d2652d85d082f83605370e29f603e28cd68838 100644 (file)
@@ -52,7 +52,7 @@ namespace MonoTests.System.Data.Odbc
                        Assert.AreEqual (OdbcType.Int, param.OdbcType, "#2");
 
                        param = new OdbcParameter ("test", 10);
-                       Assert.AreEqual (OdbcType.Int, param.OdbcType, "#3");
+                       Assert.AreEqual (OdbcType.NVarChar, param.OdbcType, "#3");
                        param.OdbcType = OdbcType.Real;
                        Assert.AreEqual (OdbcType.Real, param.OdbcType, "#4");
                        Assert.AreEqual (10, param.Value, "#5");
index d71330da060f3223633982a1db7bb3849a9bdfb1..0dfa75c3fc2b4af77318309949a0b48b55876f3d 100644 (file)
@@ -38,6 +38,7 @@ namespace MonoTests.System.Data.OleDb {
        public class OleDbParameterCollectionTest {
 
                [Test]
+               [Category ("NotWorking")] // it tries to PInvoke LocalAlloc() and fails on non-Windows.
                public void AddWithValueTest ()
                {
                        OleDbCommand command = new OleDbCommand();
index 235f7a675ea04c74da979c2894b8d56b16e9a00e..57d02f2f8616b7deed52030b68275b2b46b36ffd 100644 (file)
@@ -430,49 +430,32 @@ namespace MonoTests.System.Data.SqlClient
 
                        // Text, without parameters
                        cmd = new SqlCommand ("select count(*) from whatever");
-                       try {
-                               cmd.Prepare ();
-                               Assert.Fail ("#A1");
-                       } catch (NullReferenceException) {
-                       }
+                       cmd.Prepare ();
 
                        // Text, with parameters
                        cmd = new SqlCommand ("select count(*) from whatever");
                        cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
                        try {
                                cmd.Prepare ();
-                               Assert.Fail ("#B1");
-                       } catch (NullReferenceException) {
+                       } catch (InvalidOperationException) {
                        }
 
                        // Text, without parameters
                        cmd = new SqlCommand ("select count(*) from whatever");
                        cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
                        cmd.Parameters.Clear ();
-                       try {
-                               cmd.Prepare ();
-                               Assert.Fail ("#C1");
-                       } catch (NullReferenceException) {
-                       }
+                       cmd.Prepare ();
 
                        // StoredProcedure, without parameters
                        cmd = new SqlCommand ("FindCustomer");
                        cmd.CommandType = CommandType.StoredProcedure;
-                       try {
-                               cmd.Prepare ();
-                               Assert.Fail ("#D1");
-                       } catch (NullReferenceException) {
-                       }
+                       cmd.Prepare ();
 
                        // StoredProcedure, with parameters
                        cmd = new SqlCommand ("FindCustomer");
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
-                       try {
-                               cmd.Prepare ();
-                               Assert.Fail ("#E1");
-                       } catch (NullReferenceException) {
-                       }
+                       cmd.Prepare ();
                }
 
                [Test] // bug #412586
index 174ebc4ee004b7b05819cfe05b4f7edbebe51256..2fbdeb16c8ad740a5f0c178bec74bbcd05adc3e7 100644 (file)
@@ -332,9 +332,7 @@ namespace MonoTests.System.Data
                }
                
                [Test]
-               [Category ("NotDotNet")]
-               // Even after EndInit(), MS.NET does not fill Table property
-               // on UniqueConstraint.
+               [Ignore ("Even after EndInit(), .NET does not fill Table property on UniqueConstraint.")]
                public void TestAddRange2 ()
                {
                        DataTable table = new DataTable ("Table");
@@ -366,10 +364,12 @@ namespace MonoTests.System.Data
 
                        // After EndInit is called the constraints associated with most recent call to AddRange() must be
                        // added to the ConstraintCollection
+                       /* dunno if the above is true, but it crashes on .NET either. Disabling.
                        Assert.That (constraints [2].Table.ToString (), Is.EqualTo ("Table"), "#A03");
                        Assert.That (table.Constraints.Contains ("Unique1"), Is.True, "#A04");
                        Assert.That (table.Constraints.Contains ("Unique3"), Is.True, "#A06");
                        Assert.That (table.Constraints.Contains ("Unique2"), Is.True, "#A05");
+                       */
                }
 
                [Test]
index ad6b6d8797a3d4af8e2583f88417f0119aedd25a..1b5224112c07dee393eb9f49cc0e60ef1925fc54 100644 (file)
@@ -292,7 +292,7 @@ namespace MonoTests.System.Data
                        dc.MaxLength = int.MinValue  ;
                        //Checking Get MinValue
                        // MaxLength MinValue
-                       Assert.AreEqual(int.MinValue, dc.MaxLength , "DC31");
+                       Assert.AreEqual(-1, dc.MaxLength , "DC31");
 
                        DataTable dt = new DataTable();
                        dt.Columns.Add(new DataColumn("col",typeof(string)));
index 404c391699cb621075460074495515774c726189..05895801df047f63e6ba77a676e38b524ba13fa5 100644 (file)
@@ -174,7 +174,7 @@ namespace MonoTests.System.Data
                        //check that the DataRowView has a new DataView
                        // check that the DataRowView has a new DataView
                        dv = new DataView();
-                       Assert.AreEqual(false, drv1.DataView.Equals(dv) , "DRV21");
+                       Assert.AreEqual(true, drv1.DataView.Equals(dv) , "DRV21");
                }
 
                [Test] public void Delete()
@@ -359,7 +359,7 @@ namespace MonoTests.System.Data
 
                        dv.RowStateFilter=DataViewRowState.Deleted ;
                        // check Original
-                       Assert.AreEqual(DataRowVersion.Original , drv.RowVersion, "DRV47");
+                       Assert.AreEqual(DataRowVersion.Current , drv.RowVersion, "DRV47");
                }
        }
 }
index b2568cc65b89e940f2c19361c78c1fc58f195dc6..daec352be5baf9b672f5e99b5d4bb2bd786e57fb 100644 (file)
@@ -197,7 +197,7 @@ namespace MonoTests.System.Data
                        // namespaces
                        ds = GetDataSet (xml14, null);
                        AssertDataSet ("xml14", ds, "root", 0, 0);
-                       Assert.AreEqual ("p", ds.Prefix);
+                       Assert.AreEqual (string.Empty, ds.Prefix);
                        Assert.AreEqual ("urn:foo", ds.Namespace);
 
                        ds = GetDataSet (xml17, null);
index ec198bf5b65597fc04a2350be1ed41d01ebf77ba..08909cf76fa2f8cb74ce039632ec635ca1e4efbd 100644 (file)
@@ -567,9 +567,7 @@ namespace MonoTests.System.Data
                }
 
                [Test]
-               [Category ("NotDotNet")]
-               // MS.NET has a bug on handling default value of referenced
-               // attribute.
+               [Ignore (".NET has a bug on handling default value of referenced attribute.")]
                public void TestSampleFileValueConstraints ()
                {
                        DataSet ds = new DataSet ();
index d478b31468b7087c72cd1eab4e70a7ad3b24e9a8..ff5caaf20c7ead9613d4547f77f8c91eb7305d09 100644 (file)
@@ -578,7 +578,7 @@ namespace MonoTests.System.Data
 \r
                        AssertReadXml (ds, "SimpleTable", xml6,\r
                                XmlReadMode.Auto, XmlReadMode.InferSchema,\r
-                               "root", 1); // not NewDataSet unlike standalone load\r
+                               "NewDataSet", 1);\r
                        AssertDataTable ("seq1", ds.Tables [0], "root", 1, 1, 0, 0, 0, 0);\r
                }\r
 \r
@@ -594,7 +594,7 @@ namespace MonoTests.System.Data
 \r
                        AssertReadXml (ds, "SimpleTable2", xml7,\r
                                XmlReadMode.Auto, XmlReadMode.InferSchema,\r
-                               "root", 1); // dataset name will not be overwritten\r
+                               "NewDataSet", 1);\r
                        AssertDataTable ("#1", ds.Tables [0], "root", 2, 1, 0, 0, 0, 0);\r
 \r
                        // simple table -> simple dataset\r
index 06d86df575ea613b063c9fa73b362e2efb06d34d..3fbebc38fe2161a31094cda68499bd2854ee450c 100644 (file)
@@ -275,23 +275,7 @@ namespace MonoTests.System.Data
                        substring = TextString.Substring (0, TextString.IndexOf(EOL));
                        TextString = TextString.Substring (TextString.IndexOf(EOL) + EOL.Length);
                        // This is original DataSet.WriteXmlSchema() output
-#if MOBILE
-                       Assert.AreEqual ("              <xs:element minOccurs=\"0\" msdata:DataType=\"System.Data.SqlTypes.SqlGuid, System.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" name=\"second\" type=\"xs:string\" />", substring, "test#16");
-#elif NET_4_0
-                       Assert.AreEqual ("              <xs:element minOccurs=\"0\" msdata:DataType=\"System.Data.SqlTypes.SqlGuid, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" name=\"second\" type=\"xs:string\" />", substring, "test#16");
-#else
-                       Assert.AreEqual ("              <xs:element minOccurs=\"0\" msdata:DataType=\"System.Data.SqlTypes.SqlGuid, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" name=\"second\" type=\"xs:string\" />", substring, "test#16");
-#endif
-                       if (substring.IndexOf ("<xs:element") < 0)
-                               Assert.Fail ("test#16: " + substring);
-                       if (substring.IndexOf ("name=\"second\"") < 0)
-                               Assert.Fail ("test#16: " + substring);
-                       if (substring.IndexOf ("msdata:DataType=\"System.Data.SqlTypes.SqlGuid, System.Data, Version=") < 0)
-                               Assert.Fail ("test#16: " + substring);
-                       if (substring.IndexOf ("type=\"xs:string\"") < 0)
-                               Assert.Fail ("test#16: " + substring);
-                       if (substring.IndexOf ("minOccurs=\"0\"") < 0)
-                               Assert.Fail ("test#16: " + substring);
+                       Assert.AreEqual ("              <xs:element minOccurs=\"0\" msdata:DataType=\"System.Data.SqlTypes.SqlGuid\" name=\"second\" type=\"xs:string\" />", substring, "test#16");
                        
                        substring = TextString.Substring (0, TextString.IndexOf(EOL));
                        TextString = TextString.Substring (TextString.IndexOf(EOL) + EOL.Length);
index cc2ca7dbcebcffb14edaf4a3d7d477cc6483a0ae..510f84118c70e5fb162b074776fbbecb01a464fc 100644 (file)
@@ -35,7 +35,7 @@ using System.Text;
 
 using NUnit.Framework;
 
-namespace MonoTests.System.Data.SqlClient
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class DataTableLoadRowTest
@@ -444,8 +444,8 @@ namespace MonoTests.System.Data.SqlClient
 
                        dt.LoadDataRow (new object [] { 2, null, "mono test" }, LoadOption.OverwriteChanges);
                        Assert.AreEqual (3, dt.Rows.Count, "#1 should not have added a row");
-                       Assert.AreEqual (20, dt.Rows [1] [1], "#2 should be default value");
-                       Assert.AreEqual (20, dt.Rows [1] [1, DataRowVersion.Original], "#3 should be default value");
+                       Assert.AreEqual (25, dt.Rows [1] [1], "#2 should be default value");
+                       Assert.AreEqual (25, dt.Rows [1] [1, DataRowVersion.Original], "#3 should be default value");
 
                }
 
index 4ad9e57c96fa9d55ec53c1d0401e86a03effa575..6b85e95384251efd203e9973f1a483ac9911ba46 100644 (file)
@@ -199,7 +199,7 @@ namespace MonoTests.System.Data
                                 // Get by name
                                 Assert.AreEqual (1, (int) reader ["id"], "#1 should be able to get by name");
                                 Assert.AreEqual (333, reader.GetInt32 (ordinal), "#2 should get int32");
-                                Assert.AreEqual ("System.Int32", reader.GetDataTypeName (ordinal), "#3 data type should match");
+                                Assert.AreEqual ("Int32", reader.GetDataTypeName (ordinal), "#3 data type should match");
                         } finally {
                                 if (reader != null && !reader.IsClosed)
                                         reader.Close ();
index c46c7f37c6325560e8de28d0cd188b69980a559d..0f2d40ad39a66bceda31268280f56e33d6bd6227 100644 (file)
@@ -338,14 +338,10 @@ namespace MonoTests.System.Data
                        dt.Rows.Add (new object [] {"\t"});
                        dt.Rows.Add (new object [] {"\\"});
                        
-                       Assert.AreEqual (1, dt.Select (@"SomeCol='\t'").Length, "test#01");
-                       Assert.AreEqual (1, dt.Select (@"SomeCol='\\'").Length, "test#02");
+                       Assert.AreEqual (0, dt.Select (@"SomeCol='\t'").Length, "test#01");
+                       Assert.AreEqual (0, dt.Select (@"SomeCol='\\'").Length, "test#02");
                        
-                       try {
-                               dt.Select (@"SomeCol='\x'");
-                               Assert.Fail ("test#03");
-                       } catch (SyntaxErrorException) {
-                       }
+                       Assert.AreEqual (0, dt.Select (@"SomeCol='\x'").Length, "test#03");
                }
 
                [Test]
@@ -1999,11 +1995,11 @@ namespace MonoTests.System.Data
                }
 
                [Test]
+               [ExpectedException (typeof (ArgumentException))]
                public void ColumnObjectTypeTest() {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("Series Label", typeof(SqlInt32));
                        dt.Rows.Add(new object[] {"sss"});
-                       Assert.AreEqual (1, dt.Rows.Count);
                }
 
                private bool tableInitialized;
@@ -2014,7 +2010,7 @@ namespace MonoTests.System.Data
                        tableInitialized = false;
                        dt.Initialized += new EventHandler (OnTableInitialized);
                        dt.Columns.Add("Series Label", typeof(SqlInt32));
-                       dt.Rows.Add(new object[] {"sss"});
+                       dt.Rows.Add(new object[] {123});
                        Assert.IsFalse (tableInitialized, "TableInitialized #01");
                        dt.Initialized -= new EventHandler (OnTableInitialized);
                }
@@ -2027,7 +2023,7 @@ namespace MonoTests.System.Data
                        tableInitialized = false;
                        dt.Initialized += new EventHandler (OnTableInitialized);
                        dt.Columns.Add("Series Label", typeof(SqlInt32));
-                       dt.Rows.Add(new object[] {"sss"});
+                       dt.Rows.Add(new object[] {123});
                        dt.EndInit ();
                        dt.Initialized -= new EventHandler (OnTableInitialized);
                        Assert.IsTrue (tableInitialized, "TableInitialized #02");
@@ -2040,7 +2036,7 @@ namespace MonoTests.System.Data
                        tableInitialized = true;
                        dt.Initialized += new EventHandler (OnTableInitialized);
                        dt.Columns.Add("Series Label", typeof(SqlInt32));
-                       dt.Rows.Add(new object[] {"sss"});
+                       dt.Rows.Add(new object[] {123});
                        Assert.AreEqual (tableInitialized, dt.IsInitialized, "TableInitialized #03");
                        dt.Initialized -= new EventHandler (OnTableInitialized);
                }
@@ -2054,7 +2050,7 @@ namespace MonoTests.System.Data
                        tableInitialized = false;
                        dt.Initialized += new EventHandler (OnTableInitialized);
                        dt.Columns.Add("Series Label", typeof(SqlInt32));
-                       dt.Rows.Add(new object[] {"sss"});
+                       dt.Rows.Add(new object[] {123});
                        Assert.IsFalse (dt.IsInitialized, "TableInitialized #05");
                        dt.EndInit ();
                        Assert.IsTrue (dt.IsInitialized, "TableInitialized #06");
@@ -3245,7 +3241,8 @@ namespace MonoTests.System.Data
 
                        substring = TextString.Substring (0, TextString.IndexOf (EOL));
                        TextString = TextString.Substring (TextString.IndexOf (EOL) + EOL.Length);
-                       Assert.AreEqual ("  <xs:element msdata:IsDataSet=\"true\" msdata:Locale=\"en-US\" msdata:MainDataTable=\"Region\" name=\"Root\">", substring, "test#03");
+                       // Looks like whoever added this test depended on English culture, which is wrong.
+                       Assert.AreEqual ("  <xs:element msdata:IsDataSet=\"true\" msdata:MainDataTable=\"Region\" msdata:UseCurrentLocale=\"true\" name=\"Root\">", substring, "test#03");
 
                        substring = TextString.Substring (0, TextString.IndexOf (EOL));
                        TextString = TextString.Substring (TextString.IndexOf (EOL) + EOL.Length);
index 605655bb3690a459e8e6cbe5e967b6d4a5ce163c..6ac7f13f7529eb252652c58417f0ce9db71c273c 100644 (file)
@@ -284,8 +284,8 @@ namespace MonoTests.System.Data
                        Assert.AreEqual (tableName, table.TableName, "#6");
                        Assert.AreEqual (2, table.Constraints.Count, "#7");
                        Assert.AreEqual ("", table.Prefix, "#8");
-                       Assert.AreEqual ("Constraint1", table.Constraints [0].ToString (), "#9");
-                       Assert.AreEqual ("Constraint2", table.Constraints [1].ToString (), "#10");
+                       Assert.AreEqual ("Constraint2", table.Constraints [0].ToString (), "#9");
+                       Assert.AreEqual ("Constraint1", table.Constraints [1].ToString (), "#10");
                        Assert.AreEqual (typeof (UniqueConstraint), table.Constraints [0].GetType (), "#11");
                        Assert.AreEqual (typeof (UniqueConstraint), table.Constraints [1].GetType (), "#12");
                        Assert.AreEqual (2, table.PrimaryKey.Length, "#13");
index 0c6af80cc233bd5749a24d77afd8c374faf3740b..5ee4f8678676efc9688de525ce5d49ef54283de6 100644 (file)
@@ -326,8 +326,8 @@ namespace MonoTests.System.Data
                        Assert.AreEqual (tableName, table.TableName, "#6");
                        Assert.AreEqual (2, table.Constraints.Count, "#7");
                        Assert.AreEqual (string.Empty, table.Prefix, "#8");
-                       Assert.AreEqual ("Constraint1", table.Constraints [0].ToString (), "#9");
-                       Assert.AreEqual ("Constraint2", table.Constraints [1].ToString (), "#10");
+                       Assert.AreEqual ("Constraint2", table.Constraints [0].ToString (), "#9");
+                       Assert.AreEqual ("Constraint1", table.Constraints [1].ToString (), "#10");
                        Assert.AreEqual (typeof (UniqueConstraint), table.Constraints [0].GetType (), "#11");
                        Assert.AreEqual (typeof (UniqueConstraint), table.Constraints [1].GetType (), "#12");
                        Assert.AreEqual (2, table.PrimaryKey.Length, "#13");
@@ -424,8 +424,8 @@ namespace MonoTests.System.Data
                        Assert.AreEqual (tableName, table.TableName, "#6");
                        Assert.AreEqual (2, table.Constraints.Count, "#7");
                        Assert.AreEqual (string.Empty, table.Prefix, "#8");
-                       Assert.AreEqual ("Constraint1", table.Constraints [0].ToString (), "#9");
-                       Assert.AreEqual ("Constraint2", table.Constraints [1].ToString (), "#10");
+                       Assert.AreEqual ("Constraint2", table.Constraints [0].ToString (), "#9");
+                       Assert.AreEqual ("Constraint1", table.Constraints [1].ToString (), "#10");
                        Assert.AreEqual ("System.Data.UniqueConstraint", table.Constraints [0].GetType ().ToString (), "#11");
                        Assert.AreEqual ("System.Data.UniqueConstraint", table.Constraints [1].GetType ().ToString (), "#12");
                        Assert.AreEqual (2, table.PrimaryKey.Length, "#13");
@@ -700,7 +700,7 @@ namespace MonoTests.System.Data
                        VerifyTable_WithChildren (table, parentTable1.TableName, parentTable1.DataSet);
 
                        //Check Properties of First Child Table
-                       DataTable firstChildTable = table.ChildRelations [0].ChildTable;
+                       DataTable firstChildTable = table.ChildRelations [1].ChildTable;
                        Assert.AreEqual (string.Empty, firstChildTable.Namespace, "#1");
                        Assert.AreEqual ("XmlDataSet", firstChildTable.DataSet.DataSetName, "#2");
                        Assert.AreEqual (3, firstChildTable.Columns.Count, "#3");
@@ -720,7 +720,7 @@ namespace MonoTests.System.Data
                        Assert.AreEqual (0, firstChildTable.PrimaryKey.Length, "#17");
 
                        //Check Properties of Second Child Table
-                       DataTable secondChildTable = table.ChildRelations [1].ChildTable;
+                       DataTable secondChildTable = table.ChildRelations [0].ChildTable;
                        Assert.AreEqual (string.Empty, secondChildTable.Namespace, "#18");
                        Assert.AreEqual ("XmlDataSet", secondChildTable.DataSet.DataSetName, "#19");
                        Assert.AreEqual (4, secondChildTable.Columns.Count, "#20");
@@ -782,7 +782,7 @@ namespace MonoTests.System.Data
                        Assert.AreEqual (0, col.AutoIncrementSeed, "#15");
                        Assert.AreEqual (1, col.AutoIncrementStep, "#16");
                        Assert.AreEqual ("Element", col.ColumnMapping.ToString (), "#17");
-                       Assert.AreEqual ("ChildID", col.Caption, "#18");
+                       Assert.AreEqual ("ID", col.Caption, "#18");
                        Assert.AreEqual ("ChildID", col.ColumnName, "#19");
                        Assert.AreEqual (typeof (int), col.DataType, "#20");
                        Assert.AreEqual (string.Empty, col.DefaultValue.ToString (), "#21");
@@ -1372,7 +1372,7 @@ namespace MonoTests.System.Data
 
                        //Check the rows
                        foreach (DataRow row in table.Rows)
-                               Assert.IsNull (row [0], "#8");
+                               Assert.AreEqual (DBNull.Value, row [0], "#8");
                }
 
                [Test]
@@ -1420,19 +1420,19 @@ namespace MonoTests.System.Data
                        Assert.AreEqual (1, row ["id"], "#14");
                        Assert.AreEqual ("ParentItem 1", row ["ParentItem"], "#15");
                        Assert.AreEqual (1, row ["DepartmentID"], "#16");
-                       Assert.IsNull (row ["DummyColumn"], "#17");
+                       Assert.AreEqual (DBNull.Value, row ["DummyColumn"], "#17");
 
                        row = table.Rows [1];
                        Assert.AreEqual (2, row ["id"], "#18");
                        Assert.AreEqual ("ParentItem 2", row ["ParentItem"], "#19");
                        Assert.AreEqual (2, row ["DepartmentID"], "#20");
-                       Assert.IsNull (row ["DummyColumn"], "#21");
+                       Assert.AreEqual (DBNull.Value, row ["DummyColumn"], "#21");
 
                        row = table.Rows [2];
                        Assert.AreEqual (3, row ["id"], "#22");
                        Assert.AreEqual ("ParentItem 3", row ["ParentItem"], "#23");
                        Assert.AreEqual (3, row ["DepartmentID"], "#24");
-                       Assert.IsNull (row ["DummyColumn"], "#25");
+                       Assert.AreEqual (DBNull.Value, row ["DummyColumn"], "#25");
                }
 
                [Test]
index 0772177a2ab3190c2c7971973e4bd4c9c9e9efbf..123c878050b2034e394c84ef7eafdfd7bfe6469e 100644 (file)
@@ -127,10 +127,21 @@ namespace MonoTests.System.Data
                        dataView = null;
                }
 
+               [Test]
+               [ExpectedException (typeof (DataException))]
+               public void TestSortWithoutTable ()
+               {
+                       DataView dv = new DataView ();
+                       dv.Table = new DataTable ();
+                       dv.Sort = "abc";
+               }
+
                [Test]
                public void TestSort ()
                {
                        DataView dv = new DataView ();
+                       dv.Table = new DataTable ("dummy");
+                       dv.Table.Columns.Add ("abc");
                        dv.Sort = "abc";
                        dv.Sort = string.Empty;
                        dv.Sort = "abc";
@@ -431,10 +442,11 @@ namespace MonoTests.System.Data
                        AssertNull ("#1", dv.Table);
                        dv.EndInit ();
 
-                       AssertEquals ("#2", table, dv.Table);
+                       AssertNull ("#2", dv.Table); // still.
                        AssertEquals ("#3", 0, table.Columns.Count);
 
                        table.EndInit ();
+                       AssertEquals ("#5", table, dv.Table);
                        AssertEquals ("#4", 2, table.Columns.Count);
                }
 
@@ -462,15 +474,17 @@ namespace MonoTests.System.Data
                        dv.Table = table;
                        AssertNull ("#1", dv.Table);
                        dv.EndInit ();
-
-                       dv.Initialized -= new EventHandler (OnDataViewInitialized);
                        
-                       AssertEquals ("#2", table, dv.Table);
+                       AssertNull ("#2", dv.Table);
                        AssertEquals ("#3", 0, table.Columns.Count);
 
                        table.EndInit ();
+
+                       dv.Initialized -= new EventHandler (OnDataViewInitialized); // this should not be unregistered before table.EndInit().
+                       
                        AssertEquals ("#4", 2, table.Columns.Count);
-                       AssertEquals("DataViewInitialized #5", dvInitialized, true);
+                       AssertEquals ("#6", table, dv.Table);
+                       AssertEquals ("DataViewInitialized #5", true, dvInitialized);
                }
 
                [Test]
@@ -649,12 +663,12 @@ namespace MonoTests.System.Data
                }
 
                [Test]
-               [ExpectedException (typeof (DataException))]
+               [ExpectedException (typeof (IndexOutOfRangeException))]
                public void TestDeleteClosed ()
                {
                        DataView TestView = new DataView (dataTable);
                        TestView.Dispose (); // Close the table
-                       TestView.Delete (0);
+                       TestView.Delete (0); // cannot access to item at 0.
                }
 
                [Test] // based on bug #74631
@@ -706,7 +720,7 @@ namespace MonoTests.System.Data
                [Test]
                public void CancelEditAndEvents ()
                {
-                       string reference = " =====ItemAdded:3 ------4 =====ItemAdded:4 ------5 =====ItemAdded:5 ------6 =====ItemDeleted:5 ------5 =====ItemAdded:5";
+                       string reference = " =====ItemAdded:3 ------4 =====ItemAdded:3 =====ItemAdded:4 ------5 =====ItemAdded:4 =====ItemAdded:5 ------6 =====ItemDeleted:5 ------5 =====ItemAdded:5";
 
                        eventWriter = new StringWriter ();
 
@@ -740,7 +754,6 @@ namespace MonoTests.System.Data
                {
                        string result = @"setting table...
 ---- OnListChanged PropertyDescriptorChanged,0,0
------ UpdateIndex : True
 ---- OnListChanged Reset,-1,-1
 table was set.
 ---- OnListChanged PropertyDescriptorChanged,0,0
@@ -937,7 +950,6 @@ table changed.
                {
                        string result = @"setting table...
 ---- OnListChanged PropertyDescriptorChanged,0,0
------ UpdateIndex : True
 ---- OnListChanged Reset,-1,-1
 table was set.
 ---- OnListChanged PropertyDescriptorAdded,0,0
index 54f46f24bfecc38e928a268673ba731f0c106100..f727d736d2a05a639ce2441350bd4bb9eedc5651 100644 (file)
@@ -369,8 +369,17 @@ namespace MonoTests.System.Data
 
                        dv.Sort = "String1,ChildId";
                        // Find = wrong sort, can not find
-                       dvArr = dv.FindRows(new object[] {"3","3-String1"});
-                       Assert.AreEqual(0, dvArr.Length  , "DV42");
+                       try 
+                       {
+                               dvArr = dv.FindRows(new object[] {"3","3-String1"});
+                               Assert.Fail("DV42: FindRows Failed to throw ArgumentException");
+                       }
+                       catch (FormatException) {}
+                       catch (AssertionException exc) {throw  exc;}
+                       catch (Exception exc)
+                       {
+                               Assert.Fail("DV42-2: FindRows. Wrong exception type. Got:" + exc);
+                       }
 
                        dv.Sort = "ChildId,String1";
 
@@ -481,8 +490,17 @@ namespace MonoTests.System.Data
 
                        dv.Sort = "String1,ParentId";
                        // Find = wrong sort, can not find
-                       FindResult = dv.Find(new object[] {"3","3-String1"});
-                       Assert.AreEqual(-1, FindResult , "DV51");
+                       try 
+                       {
+                               FindResult = dv.Find(new object[] {"3","3-String1"});
+                               Assert.Fail("DV51: Find Failed to throw ArgumentException");
+                       }
+                       catch (FormatException) {}
+                       catch (AssertionException exc) {throw  exc;}
+                       catch (Exception exc)
+                       {
+                               Assert.Fail("DV51-2: Find. Wrong exception type. Got:" + exc);
+                       }
 
                        dv.Sort = "ParentId,String1";
                        // Find 
@@ -562,7 +580,7 @@ namespace MonoTests.System.Data
                        // change value - NewIndex
                        Assert.AreEqual(1, evProp.NewIndex, "DV60");
                        // change value - OldIndex
-                       Assert.AreEqual(-1, evProp.OldIndex , "DV61");
+                       Assert.AreEqual(1, evProp.OldIndex , "DV61");
 
                        // ----- Add New ---------
                        evProp = null;
@@ -1127,7 +1145,7 @@ namespace MonoTests.System.Data
                        evProp = null;
                        table.Rows[0][0] = 5;
                        Assert.AreEqual (0, evProp.NewIndex, "#4");
-                       Assert.AreEqual (-1, evProp.OldIndex, "#5");
+                       Assert.AreEqual (0, evProp.OldIndex, "#5");
                        Assert.AreEqual (ListChangedType.ItemChanged, evProp.lstType, "#6");
 
                        evProp = null;
index 8328f7ebbb2f8afceca220b23d95d5ce8d46052e..6e5d2a4df927114b5c0499ff38153f2b41c00ba5 100644 (file)
@@ -212,6 +212,7 @@ namespace MonoTests.System.Data
                        try {
                                DataTable tmp = fkc.Table;
                                Fail ("When table is null, get_Table causes an InvalidOperationException.");
+                       } catch (NullReferenceException) { // actually .NET throws this (bug)
                        } catch (InvalidOperationException) {
                        }
                                                                                                     
@@ -226,7 +227,7 @@ namespace MonoTests.System.Data
                                 throw new ApplicationException ("An Exception was expected");
                         }
                         // LAMESPEC : spec says InvalidConstraintException but throws this
-                        catch (ArgumentException) {
+                        catch (NullReferenceException) {
                         }
 
 #if false // FIXME: Here this test crashes under MS.NET.
@@ -451,7 +452,7 @@ namespace MonoTests.System.Data
 
                        Assert( "Equals failed diff. 1" , fkc.Equals(fkcDiff) == false);
 
-                       Assert( "Hash Code Failed. 1", fkc.GetHashCode() == fkc2.GetHashCode() );
+                       //Assert( "Hash Code Failed. 1", fkc.GetHashCode() == fkc2.GetHashCode() );
                        Assert( "Hash Code Failed. 2", fkc.GetHashCode() != fkcDiff.GetHashCode() );
        
                }
index c47c0bd597d945847e9e61621d5398aaa9ec43d7..2be7b264d09d432d6411966d0ded3330209fe21c 100644 (file)
@@ -203,8 +203,8 @@ namespace MonoTests.System.Data
                        Assert.That (cst3.Equals (cst), Is.False, "A3");
                        Assert.That (cst.Equals (cst4), Is.False, "A4");
 
-                       //true
-                       Assert.That (cst.GetHashCode (), Is.EqualTo (cst2.GetHashCode ()), "HashEquals");
+                       //false... but it should be true (FXDG violation)
+                       //Assert.That (cst.GetHashCode (), Is.Not.EqualTo (cst2.GetHashCode ()), "HashEquals");
 
                        //false
                        Assert.That (cst.GetHashCode (), Is.Not.EqualTo (cst3.GetHashCode ()), "Hash Not Equals");