Author: senga
Date: 2006-04-18 05:58:08 -0400 (Tue, 18 Apr 2006)
New Revision: 59582

Modified:
   trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
   trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
Log:
2006-04-18  Senganal T  <[EMAIL PROTECTED]>

        * Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs :
                - OpenTest_1 : test InvalidOperationException is raised if
                ConnectionString is empty
                - DisposeTest : test nullreference exception is not raised
        * System.Data.SqlClient/SqlConnection.cs :
                - SetConnectionString : set the pareameter to default values
                if connection string is empty or null
                - Open : Raise InvalidOperationException if Connection String
                is empty or null
                - Dispose : Test exception not raised if dispose called on a
                connection with empty connection string

        slight modification of the patch by Jonel Rienton



Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2006-04-18 
09:48:46 UTC (rev 59581)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2006-04-18 
09:58:08 UTC (rev 59582)
@@ -1,3 +1,15 @@
+2006-04-18  Senganal T  <[EMAIL PROTECTED]>
+
+       * SqlConnection.cs :
+               - SetConnectionString : set the pareameter to default values
+               if connection string is empty or null
+               - Open : Raise InvalidOperationException if Connection String
+               is empty or null
+               - Dispose : Test exception not raised if dispose called on a
+               connection with empty connection string
+
+       slight modification of the patch by Jonel Rienton
+
 2006-04-07  Senganal T  <[EMAIL PROTECTED]>
 
        * SqlCommandBuilder.cs :

Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs  
2006-04-18 09:48:46 UTC (rev 59581)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs  
2006-04-18 09:58:08 UTC (rev 59582)
@@ -436,19 +436,19 @@
 
                protected override void Dispose (bool disposing) 
                {
-                       if (!disposed) { 
-                                try {
-                                        if (disposing) {
-                                                if (State == 
ConnectionState.Open) 
-                                                        Close ();
-                                                parms.Reset ();
-                                                ConnectionString = "";
-                                               SetDefaultConnectionParameters 
(this.connStringParameters); 
-                                        }
-                                } finally {
-                                        disposed = true;
-                                        base.Dispose (disposing);
-                                }
+                       if (disposed)
+                               return;
+
+                       try {
+                               if (disposing) {
+                                       if (State == ConnectionState.Open) 
+                                               Close ();
+                                       ConnectionString = "";
+                                       SetDefaultConnectionParameters 
(this.connStringParameters); 
+                               }
+                       } finally {
+                               disposed = true;
+                               base.Dispose (disposing);
                        }
                }
 
@@ -503,7 +503,7 @@
                        if (state == ConnectionState.Open)
                                throw new InvalidOperationException ("The 
Connection is already Open (State=Open)");
 
-                       if (connectionString == null)
+                       if (connectionString == null || 
connectionString.Trim().Length == 0)
                                throw new InvalidOperationException 
("Connection string has not been initialized.");
 
                        try {
@@ -552,7 +552,7 @@
                        string theInstanceName = "";
        
                        if (theDataSource == null)
-                               throw new ArgumentException("Format of 
initialization string doesnot conform to specifications");
+                               throw new ArgumentException("Format of 
initialization string does not conform to specifications");
 
                        thePort = 1433; // default TCP port for SQL Server
                        bool success = true;
@@ -633,8 +633,9 @@
                         NameValueCollection parameters = new 
NameValueCollection ();
                         SetDefaultConnectionParameters (parameters);
 
-                       if ((connectionString == null) || 
(connectionString.Length == 0)) {
-                                this.connectionString = connectionString;
+                       if ((connectionString == null) || 
(connectionString.Trim().Length == 0)) {
+                               this.connectionString = connectionString;
+                               this.connStringParameters = parameters;
                                return;
                         }
 

Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog  
    2006-04-18 09:48:46 UTC (rev 59581)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog  
    2006-04-18 09:58:08 UTC (rev 59582)
@@ -1,3 +1,10 @@
+2006-04-18  Senganal T  <[EMAIL PROTECTED]>
+
+       * SqlConnectionTest.cs :
+               - OpenTest_1 : test InvalidOperationException is raised if
+               ConnectionString is empty
+               - DisposeTest : test nullreference exception is not raised
+
 2006-04-07  Senganal T  <[EMAIL PROTECTED]>
 
        * SqlDataAdapterTest,cs :

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-04-18 09:48:46 UTC (rev 59581)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
   2006-04-18 09:58:08 UTC (rev 59582)
@@ -169,9 +169,9 @@
                                try {
                                        conn.ConnectionString = connString;
                                        conn.Open();
-                                       Assert.AreEqual (typeof (SqlException), 
null,
-                                               string.Format (
+                                       Assert.Fail (String.Format (
                                                        "#1_{0} Incorrect 
Connection String",count));                           
+                                               
                                }catch (AssertionException e) {
                                        throw e;
                                }catch (Exception e) {
@@ -216,6 +216,26 @@
                }
 
                [Test]
+               public void OpenTest_1 ()
+               {
+                       SqlConnection conn  = new SqlConnection ();
+
+                       conn.ConnectionString = "";
+                       try {
+                               conn.Open ();
+                               Assert.Fail ("#1 Should throw ArgumentException 
and not SqlException");
+                       } catch (InvalidOperationException) {
+                       }
+
+                       conn.ConnectionString = "    ";
+                       try {
+                               conn.Open ();
+                               Assert.Fail ("#2 Should throw ArgumentException 
and not SqlException");
+                       } catch (InvalidOperationException) {
+                       }
+               }
+
+               [Test]
                public void CreateCommandTest ()
                {
                        conn = new SqlConnection (connectionString);
@@ -257,6 +277,10 @@
                                "#6 Default Workstationid : hostname");
                        Assert.AreEqual (ConnectionState.Closed, conn.State, 
                                "#7 Default State : CLOSED ");
+
+                       conn = new SqlConnection ();
+                       //shud not throw exception
+                       conn.Dispose ();
                }
 
                [Test]

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

Reply via email to