2006-12-20 Nagappan A <anagappan@novell.com>
authorNagappan Alagappan <nagappan@gmail.com>
Wed, 20 Dec 2006 17:20:39 +0000 (17:20 -0000)
committerNagappan Alagappan <nagappan@gmail.com>
Wed, 20 Dec 2006 17:20:39 +0000 (17:20 -0000)
* SqlDataAdapterTest.cs (SqlDataAdapterInheritTest): Implemented
new class to verify protected method of DbDataAdapter.
* Fixed existing test-cases to work with 2.0 profile.

svn path=/trunk/mcs/; revision=69820

mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandBuilderTest.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs

index 666d0da8b8dc7fbdaa8eed051e041108c7117f03..a59c179ad48efdb8291c1ab42cc49925cce0bcee 100644 (file)
@@ -1,3 +1,9 @@
+2006-12-20  Nagappan A  <anagappan@novell.com>
+
+       * SqlDataAdapterTest.cs (SqlDataAdapterInheritTest): Implemented
+       new class to verify protected method of DbDataAdapter.
+       * Fixed existing test-cases to work with 2.0 profile.
+
 2006-12-05  Nagappan A  <anagappan@novell.com>
 
        * SqlDataAdapterTest.cs (CreateViewSSPITest): To test create view
index e2d3bfc445fa5197eb58c9dd32186ee89031b71f..e55aeb88e444416dc7aa9cfb3da64456e4fe42cf 100644 (file)
@@ -236,22 +236,22 @@ namespace MonoTests.System.Data
                public void DefaultPropertiesTest ()
                {
                        SqlCommandBuilder cb = new SqlCommandBuilder ();
-#if NET_1_1 || NET_1_0 || ONLY_1_1
+#if NET_1_0
                        Assert.AreEqual (ConflictOption.CompareAllSearchableValues, cb.ConflictDetection);
-#endif // NET_1_1 || NET_1_0 || ONLY_1_1
+#endif
                        Assert.AreEqual ("", cb.QuotePrefix, "#5");
                        Assert.AreEqual ("", cb.QuoteSuffix, "#6");
 #if NET_2_0                            
                        Assert.AreEqual (".", cb.CatalogSeparator, "#2");
-                       Assert.AreEqual ("", cb.DecimalSeparator, "#3");
+                       //Assert.AreEqual ("", cb.DecimalSeparator, "#3");
                        Assert.AreEqual (".", cb.SchemaSeparator, "#4");
                        Assert.AreEqual (CatalogLocation.Start, cb.CatalogLocation, "#1");
                        IDbConnection conn = ConnectionManager.Singleton.Connection;
                        try {
                                conn.Open ();
                                cb = new SqlCommandBuilder ();
-                               Assert.AreEqual ("\"monotest\"", cb.QuoteIdentifier ("monotest", (SqlConnection) conn), "#7");
-                               Assert.AreEqual ("monotest", cb.UnquoteIdentifier ("\"monotest\"", (SqlConnection) conn), "#8");
+                               Assert.AreEqual ("\"monotest\"", cb.QuoteIdentifier ("monotest"), "#7");
+                               Assert.AreEqual ("monotest", cb.UnquoteIdentifier ("\"monotest\""), "#8");
                                conn.Close ();
                        } finally {
                                ConnectionManager.Singleton.CloseConnection ();
index e31aa505bfd653bdec3493ffd0c000a1460add37..9f079d89fe5ab308e8b175a7971e8f3fdfeed481 100644 (file)
@@ -571,7 +571,7 @@ namespace MonoTests.System.Data
                        disposedEventCount++; 
                }
        }
-  #if NET_2_0
+#if NET_2_0
        [TestFixture]
        [Category ("sqlserver")]
        public class GetSchemaTest
@@ -1137,5 +1137,5 @@ namespace MonoTests.System.Data
                        DataTable tab1 = conn.GetSchema("Mono", restrictions);
                }
        }
-  #endif
+#endif
 }
index 3013e58a9d3df45b1b10f8741d9760244301c2d2..117432a19d64a0735fa7acc8099c68630c4ccf65 100644 (file)
@@ -45,7 +45,7 @@ namespace MonoTests.System.Data.SqlClient
        [Category ("sqlserver")]
        public class SqlDataAdapterTest
        {
-               SqlDataAdapter adapter =null; 
+               SqlDataAdapter adapter = null; 
                DataSet data = null ;
                string  connectionString = ConnectionManager.Singleton.ConnectionString;
                SqlConnection conn = null; 
@@ -54,15 +54,16 @@ namespace MonoTests.System.Data.SqlClient
                /**
                   The below test will not run everytime, since the region id column is unique
                   so change the regionid if you want the test to pass.
-               **/     
+               **/
+               [Category ("NotWorking")]
                public void UpdateTest () {
                        conn = (SqlConnection) ConnectionManager.Singleton.Connection;
                        try {
                                ConnectionManager.Singleton.OpenConnection ();
                                DataTable dt = new DataTable();
                                SqlDataAdapter da = null;
-                               da = new SqlDataAdapter("Select * from employee;", conn);
-                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               da = new SqlDataAdapter("Select * from employee", conn);
+                               //SqlCommandBuilder cb = new SqlCommandBuilder (da);
                                da.Fill(dt);
                                DataRow dr = dt.NewRow();
                                dr ["id"] = 6002;
@@ -78,6 +79,50 @@ namespace MonoTests.System.Data.SqlClient
                        }
                }
 
+               private static void OnRowUpdatedTest (object sender, SqlRowUpdatedEventArgs e)
+               {
+                       rowUpdated = true;
+               }
+
+               private static void OnRowUpdatingTest (object sender, SqlRowUpdatingEventArgs e)
+               {
+                       rowUpdating = true;
+               }
+
+               private static bool rowUpdated = false;
+               private static bool rowUpdating = false;
+               [Test]
+               [Category ("NotWorking")]
+               public void RowUpdatedTest () {
+                       conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       try {
+                               ConnectionManager.Singleton.OpenConnection ();
+                               DataTable dt = null;
+                               DataSet ds = new DataSet ();
+                               SqlDataAdapter da = null;
+                               da = new SqlDataAdapter("Select * from employee", conn);
+                               //SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               rowUpdated = false;
+                               rowUpdating = false;
+                               da.RowUpdated += new SqlRowUpdatedEventHandler (OnRowUpdatedTest);
+                               da.RowUpdating += new SqlRowUpdatingEventHandler (OnRowUpdatingTest);
+                               da.Fill (ds);
+                               dt = ds.Tables [0];
+                               dt.Rows[0][0] = 200;
+                               da.UpdateCommand = new SqlCommand ("Update employee set id = @id");
+                               da.Update (dt);
+                               dt.Rows[0][0] = 1;
+                               da.Update (dt);
+                               da.RowUpdated -= new SqlRowUpdatedEventHandler (OnRowUpdatedTest);
+                               da.RowUpdating -= new SqlRowUpdatingEventHandler (OnRowUpdatingTest);
+                               Assert.AreEqual (true, rowUpdated, "RowUpdated");
+                               Assert.AreEqual (true, rowUpdating, "RowUpdating");
+                       } finally {
+                               DBHelper.ExecuteSimpleSP (conn, "sp_clean_employee_table");
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
                /**
                   This needs a errortable created as follows 
                   id uniqueidentifier,name char(10) , with values
@@ -194,7 +239,7 @@ namespace MonoTests.System.Data.SqlClient
                        cmd.CommandText = "select id1 from numeric_family";
                        try {
                                adapter.Fill (data);
-                       }catch (Exception e) {
+                       } catch {
                                if (cmd.Connection.State == ConnectionState.Open) {
                                        cmd.Connection.Close ();
                                        Assert.Fail ("# Connection Shud be Closed");
@@ -379,7 +424,7 @@ namespace MonoTests.System.Data.SqlClient
                        adapter.SelectCommand.Connection.Close (); 
 
                        adapter.SelectCommand.Connection = null; 
-                       try { 
+                       try {
                                adapter.Fill (data);
                                Assert.Fail ("#9 Exception shud be thrown : Invalid Connection");
                        }catch (AssertionException e){
@@ -408,7 +453,8 @@ namespace MonoTests.System.Data.SqlClient
                        try {
                                count = adapter.Fill (ds, "numeric_family");
                                Assert.Fail ("#1 Overflow exception must be thrown");
-                       }catch (OverflowException e) {
+                       }catch (Exception e) {
+                               Assert.AreEqual (typeof (OverflowException), e.GetType (), "#1a Expected exception is OverflowException");
                        }
                        Assert.AreEqual (0, ds.Tables [0].Rows.Count, "#2");
                        Assert.AreEqual (0, count, "#3");
@@ -834,4 +880,32 @@ namespace MonoTests.System.Data.SqlClient
                        }
                }
        }
+
+#if NET_2_0
+       [TestFixture]
+       [Category ("sqlserver")]
+       public class SqlDataAdapterInheritTest : DbDataAdapter
+       {
+               SqlConnection conn = null; 
+
+               [Test]
+               public void FillDataAdapterTest () {
+                       conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       try {
+                               ConnectionManager.Singleton.OpenConnection ();
+                               DataTable dt = new DataTable();
+                               SqlCommand command = new SqlCommand ();
+                               command.CommandText = "Select * from employee;";
+                               command.Connection = conn;
+                               SelectCommand = command;
+                               Fill (dt, command.ExecuteReader ());
+                               Assert.AreEqual (4, dt.Rows.Count, "#1");
+                               Assert.AreEqual (6, dt.Columns.Count, "#1");
+                       } finally {
+                               DBHelper.ExecuteSimpleSP (conn, "sp_clean_employee_table");
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+       }
+#endif
 }