2007-03-09 Andreia Gaita <avidigal@novell.com>
authorAndreia Gaita <avidigal@novell.com>
Fri, 9 Mar 2007 13:51:10 +0000 (13:51 -0000)
committerAndreia Gaita <avidigal@novell.com>
Fri, 9 Mar 2007 13:51:10 +0000 (13:51 -0000)
* SqlCommandTest.cs: Add new test to check string parameters with
value = null and size 0. Fixed tests for NET 2.0 (different exceptions
thrown)

* ConnectionManager.cs: small fix to close the connection if we
mean to change the connection string and open it again

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

mcs/class/System.Data/Test/ProviderTests/Common/ChangeLog
mcs/class/System.Data/Test/ProviderTests/Common/ConnectionManager.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs

index c24b8564794afcf6ff66945d2e9b71dbea0db29b..ecc5d36ea3cf7b220d8b8329ff9dd4c0b622fd2b 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-09  Andreia Gaita  <avidigal@novell.com>
+
+       * ConnectionManager.cs: small fix to close the connection if we 
+       mean to change the connection string and open it again
+
 2005-09-16  Senganal T  <tsenganal@novell.com>
 
        * DataProvider.cs : Provides data for validation
index b41458ce5bba9ab4698fec6042d3660cd5662239..ddfbc3eabf19cce2872f321517f2fc0af5c9e13f 100644 (file)
@@ -75,6 +75,8 @@ namespace MonoTests.System.Data
                {
                        if (_connection == null)
                                _connection = ProviderFactory.CreateConnectionFromConfig ("ConnString");
+                       if (!(_connection.State == ConnectionState.Closed || _connection.State == ConnectionState.Broken))
+                               _connection.Close ();
                        _connection.ConnectionString = _connectionString;
                        _connection.Open ();
                }
index 9c1cedb0a7baea6ee201a13c8837a2bb9f3b6525..b0f72f087c604e57ed6f5e6a257770628e441c66 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-09  Andreia Gaita  <avidigal@novell.com>
+
+       * SqlCommandTest.cs: Add new test to check string parameters with 
+       value = null and size 0. Fixed tests for NET 2.0 (different exceptions
+       thrown)
+
 2007-03-09  Andreia Gaita  <avidigal@novell.com>
 
        * SqlCommandTest.cs: Add parameterized stored procedure call tests
index 27efa0677b453d4a8460f7b9ab062613524d92fd..32522cadde70cd1c53a772938c7ed3e9a0fd6e43 100644 (file)
@@ -221,6 +221,23 @@ namespace MonoTests.System.Data.SqlClient
                        Assert.AreEqual (return_value, result, "#8 ExecuteScalar Should return 'first column of first rowset'");
                        Assert.AreEqual (int_value * 2, p2.Value, "#9 ExecuteScalar should fill the parameter collection with the outputted values");
                        Assert.AreEqual (string_value, p3.Value, "#10 ExecuteScalar should fill the parameter collection with the outputted values");
+
+                       p3.Size = 0;
+                       p3.Value = null;
+                       try {
+                               cmd.ExecuteScalar ();
+                               Assert.Fail ("#11 Query should throw System.InvalidOperationException due to size = 0 and value = null");
+                       }
+                       catch (AssertionException e) {
+                               throw e;
+                       }
+                       catch (Exception e) {
+                               Assert.AreEqual (typeof (InvalidOperationException), e.GetType (),
+                                       "#12 Incorrect Exception : " + e.StackTrace);
+                       }
+
+                       conn.Close ();
+                       
                }
 
                [Test]
@@ -546,12 +563,22 @@ namespace MonoTests.System.Data.SqlClient
                        cmd.Connection = null; 
                        try {
                                cmd.Prepare ();
-                               Assert.Fail ("#8 InvalidOperation Exception shud be thrown");
-                       }catch (AssertionException e) {
+#if NET_2_0
+                               Assert.Fail ("#8 NullReferenceException should be thrown");
+#else
+                               Assert.Fail ("#8 InvalidOperation Exception should be thrown");
+#endif
+                       }
+                       catch (AssertionException e) {
                                throw e; 
                        }catch (Exception e) {
-                               Assert.AreEqual (typeof(InvalidOperationException), e.GetType(),
+#if NET_2_0
+                               Assert.AreEqual (typeof (NullReferenceException), e.GetType (),
+                                       "#9 Incorrect Exception : " + e.StackTrace);
+#else
+                               Assert.AreEqual (typeof (InvalidOperationException), e.GetType (),
                                        "#9 Incorrect Exception : " + e.StackTrace);
+#endif
                        }
 
                        //Test InvalidOperation Exception is thrown if connection is closed
@@ -590,7 +617,11 @@ namespace MonoTests.System.Data.SqlClient
                }
                
                [Test]
+#if NET_2_0
+               [ExpectedException (typeof(ArgumentOutOfRangeException))]
+#else
                [ExpectedException (typeof(ArgumentException))]
+#endif
                public void CommandTypeTest ()
                {
                        cmd = new SqlCommand ();
@@ -643,7 +674,11 @@ namespace MonoTests.System.Data.SqlClient
 
                // Need to add more tests
                [Test]
+#if NET_2_0
+               [ExpectedException (typeof(ArgumentOutOfRangeException))]
+#else
                [ExpectedException (typeof(ArgumentException))]
+#endif
                public void UpdatedRowSourceTest ()
                {
                        cmd = new SqlCommand ();