Author: anagappan
Date: 2006-12-20 12:20:39 -0500 (Wed, 20 Dec 2006)
New Revision: 69820

Modified:
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandBuilderTest.cs
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs
Log:
2006-12-20  Nagappan A  <[EMAIL PROTECTED]>

        * SqlDataAdapterTest.cs (SqlDataAdapterInheritTest): Implemented
        new class to verify protected method of DbDataAdapter.
        * Fixed existing test-cases to work with 2.0 profile.



Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog  
    2006-12-20 17:18:45 UTC (rev 69819)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog  
    2006-12-20 17:20:39 UTC (rev 69820)
@@ -1,3 +1,9 @@
+2006-12-20  Nagappan A  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * SqlDataAdapterTest.cs (CreateViewSSPITest): To test create view

Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandBuilderTest.cs
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandBuilderTest.cs
       2006-12-20 17:18:45 UTC (rev 69819)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandBuilderTest.cs
       2006-12-20 17:20:39 UTC (rev 69820)
@@ -236,22 +236,22 @@
                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 ();

Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
   2006-12-20 17:18:45 UTC (rev 69819)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
   2006-12-20 17:20:39 UTC (rev 69820)
@@ -571,7 +571,7 @@
                        disposedEventCount++; 
                }
        }
-  #if NET_2_0
+#if NET_2_0
        [TestFixture]
        [Category ("sqlserver")]
        public class GetSchemaTest
@@ -1137,5 +1137,5 @@
                        DataTable tab1 = conn.GetSchema("Mono", restrictions);
                }
        }
-  #endif
+#endif
 }

Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs
  2006-12-20 17:18:45 UTC (rev 69819)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs
  2006-12-20 17:20:39 UTC (rev 69820)
@@ -45,7 +45,7 @@
        [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 @@
                /**
                   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 @@
                        }
                }
 
+               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 @@
                        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 @@
                        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 @@
                        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 @@
                        }
                }
        }
+
+#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
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to