Explorar o código

* SqlCommandBuilderTest.cs: Fixes for SQL Server 7.0 / TDS 7.
* SqlCommandTest.cs: Fixes for SQL Server 7.0 / TDS 7.
* SqlConnectionTest.cs: Fixes for SQL Server 7.0 / TDS 7.
* SqlDataAdapterTest.cs: Added tests for Update. Fixed Fill_Test_Data,
Fill_Test_PriKey and Fill_Test_FillErrorTest to pass on SQL Server 7.0.
Avoid catching and rethrowing AssertionException. Minor improvements.
* SqlParameterTest.cs: Fixes for SQL Server 7.0 / TDS 7. Updated
ZeroLengthString to pass on 1.0 profile.
* SqlTransactionTest.cs: Fixes for SQL Server 7.0 / TDS 7.

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

Gert Driesen %!s(int64=16) %!d(string=hai) anos
pai
achega
b5fa4ed568

+ 12 - 0
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog

@@ -1,3 +1,15 @@
+2009-08-01  Gert Driesen  <[email protected]>
+
+	* SqlCommandBuilderTest.cs: Fixes for SQL Server 7.0 / TDS 7.
+	* SqlCommandTest.cs: Fixes for SQL Server 7.0 / TDS 7.
+	* SqlConnectionTest.cs: Fixes for SQL Server 7.0 / TDS 7.
+	* SqlDataAdapterTest.cs: Added tests for Update. Fixed Fill_Test_Data,
+	Fill_Test_PriKey and Fill_Test_FillErrorTest to pass on SQL Server 7.0.
+	Avoid catching and rethrowing AssertionException. Minor improvements.
+	* SqlParameterTest.cs: Fixes for SQL Server 7.0 / TDS 7. Updated
+	ZeroLengthString to pass on 1.0 profile.
+	* SqlTransactionTest.cs: Fixes for SQL Server 7.0 / TDS 7.
+
 2009-07-30  Gert Driesen  <[email protected]>
 
 	* SqlParameterTest.cs: Improved tests for bug #382589.

+ 23 - 12
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandBuilderTest.cs

@@ -317,6 +317,9 @@ namespace MonoTests.System.Data
 		[Test] // GetUpdateCommand ()
 		public void GetUpdateCommand1_AutoIncrement ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Key information is not available for temporary tables.");
+
 			SqlCommand cmd = null;
 
 			try {
@@ -692,6 +695,9 @@ namespace MonoTests.System.Data
 		[Test] // GetDeleteCommand ()
 		public void GetDeleteCommand1_AutoIncrement ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Key information is not available for temporary tables.");
+
 			SqlCommand cmd = null;
 
 			try {
@@ -948,7 +954,10 @@ namespace MonoTests.System.Data
 				param = cmd.Parameters [0];
 				Assert.AreEqual (ParameterDirection.ReturnValue, param.Direction, "#B:Direction");
 				Assert.IsFalse (param.IsNullable, "#B:IsNullable");
-				Assert.AreEqual ("@RETURN_VALUE", param.ParameterName, "#B:ParameterName");
+				if (ClientVersion == 7)
+					Assert.AreEqual ("RETURN_VALUE", param.ParameterName, "#B:ParameterName");
+				else
+					Assert.AreEqual ("@RETURN_VALUE", param.ParameterName, "#B:ParameterName");
 				Assert.AreEqual (0, param.Precision, "#B:Precision");
 				Assert.AreEqual (0, param.Scale, "#B:Scale");
 				//Assert.AreEqual (0, param.Size, "#B:Size");
@@ -970,7 +979,10 @@ namespace MonoTests.System.Data
 				Assert.IsFalse (param.IsNullable, "#D:IsNullable");
 				Assert.AreEqual ("@param1", param.ParameterName, "#D:ParameterName");
 				Assert.AreEqual (5, param.Precision, "#D:Precision");
-				Assert.AreEqual (3, param.Scale, "#D:Scale");
+				if (ClientVersion == 7)
+					Assert.AreEqual (2, param.Scale, "#D:Scale");
+				else
+					Assert.AreEqual (3, param.Scale, "#D:Scale");
 				//Assert.AreEqual (0, param.Size, "#D:Size");
 				Assert.AreEqual (SqlDbType.Decimal, param.SqlDbType, "#D:SqlDbType");
 				Assert.IsNull (param.Value, "#D:Value");
@@ -989,7 +1001,10 @@ namespace MonoTests.System.Data
 				cmd.Parameters ["@param1"].Value = 4.000m;
 				cmd.Parameters ["@param2"].Value = DBNull.Value;
 				cmd.ExecuteNonQuery ();
-				Assert.AreEqual (666, cmd.Parameters ["@RETURN_VALUE"].Value, "#F1");
+				if (ClientVersion == 7)
+					Assert.AreEqual (666, cmd.Parameters ["RETURN_VALUE"].Value, "#F1");
+				else
+					Assert.AreEqual (666, cmd.Parameters ["@RETURN_VALUE"].Value, "#F1");
 				Assert.AreEqual (5, cmd.Parameters ["@param0"].Value, "#F2");
 				Assert.AreEqual (11m, cmd.Parameters ["@param1"].Value, "#F3");
 				Assert.AreEqual (DBNull.Value, cmd.Parameters ["@param2"].Value, "#F4");
@@ -1382,9 +1397,7 @@ namespace MonoTests.System.Data
 #endif
 			Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (3)");
 #if NET_2_0
-			Assert.IsNotNull (param.SqlValue, prefix + "SqlValue (3)");
-			Assert.AreEqual (typeof (SqlInt32), param.SqlValue.GetType (), prefix + "SqlValue (3)");
-			Assert.AreEqual (1, ((SqlInt32) param.SqlValue).Value, prefix + "SqlValue (3)");
+			Assert.AreEqual (new SqlInt32 (1), param.SqlValue, prefix + "SqlValue (3)");
 			//Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (3)");
 #endif
 			Assert.AreEqual (1, param.Value, prefix + "Value (3)");
@@ -1560,7 +1573,7 @@ namespace MonoTests.System.Data
 				Assert.AreEqual ("@p1", param.ParameterName, prefix + "ParameterName (0)");
 
 			if (ClientVersion > 7)
-			   	Assert.AreEqual (0, param.Precision, prefix + "Precision (0)");
+				Assert.AreEqual (0, param.Precision, prefix + "Precision (0)");
 			else
 				Assert.AreEqual (10, param.Precision, prefix + "Precision (0)");
 
@@ -1656,7 +1669,7 @@ namespace MonoTests.System.Data
 				Assert.AreEqual ("@p4", param.ParameterName, prefix + "ParameterName (3)");
 
 			if (ClientVersion > 7)
-			   	Assert.AreEqual (0, param.Precision, prefix + "Precision (0)");
+				Assert.AreEqual (0, param.Precision, prefix + "Precision (0)");
 			else
 				Assert.AreEqual (10, param.Precision, prefix + "Precision (0)");
 
@@ -1766,9 +1779,7 @@ namespace MonoTests.System.Data
 #endif
 			Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (6)");
 #if NET_2_0
-			Assert.IsNotNull (param.SqlValue, prefix + "SqlValue (6)");
-			Assert.AreEqual (typeof (SqlInt32), param.SqlValue.GetType (), prefix + "SqlValue (6)");
-			Assert.AreEqual (1, ((SqlInt32) param.SqlValue).Value, prefix + "SqlValue (6)");
+			Assert.AreEqual (new SqlInt32 (1), param.SqlValue, prefix + "SqlValue (6)");
 			//Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (6)");
 #endif
 			Assert.AreEqual (1, param.Value, prefix + "Value (6)");
@@ -1821,7 +1832,7 @@ namespace MonoTests.System.Data
 		}
 
 		static int ClientVersion {
-		        get {
+			get {
 				return (SqlCommandBuilderTest.Engine.ClientVersion);
 			}
 		}

+ 52 - 12
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs

@@ -52,10 +52,17 @@ namespace MonoTests.System.Data.SqlClient
 		SqlConnection conn;
 		SqlCommand cmd;
 		string connectionString = ConnectionManager.Singleton.ConnectionString;
+		EngineConfig engine;
 
 		static readonly decimal SMALLMONEY_MAX = 214748.3647m;
 		static readonly decimal SMALLMONEY_MIN = -214748.3648m;
 
+		[SetUp]
+		public void SetUp ()
+		{
+			engine = ConnectionManager.Singleton.Engine;
+		}
+
 		[TearDown]
 		public void TearDown ()
 		{
@@ -187,13 +194,19 @@ namespace MonoTests.System.Data.SqlClient
 				result = cmd.ExecuteScalar ();
 				Assert.Fail ("#B1");
 			} catch (SqlException ex) {
-				// Incorrect syntax near the keyword 'from'
 				Assert.AreEqual (typeof (SqlException), ex.GetType (), "#B2");
 				Assert.AreEqual ((byte) 15, ex.Class, "#B3");
 				Assert.IsNull (ex.InnerException, "#B4");
 				Assert.IsNotNull (ex.Message, "#B5");
-				Assert.IsTrue (ex.Message.IndexOf ("'from'") != -1, "#B6:"+ ex.Message);
-				Assert.AreEqual (156, ex.Number, "#B7");
+				if (ClientVersion == 7) {
+					// Incorrect syntax near '*'
+					Assert.IsTrue (ex.Message.IndexOf ("'*'") != -1, "#B6: " + ex.Message);
+					Assert.AreEqual (170, ex.Number, "#B7");
+				} else {
+					// Incorrect syntax near the keyword 'from'
+					Assert.IsTrue (ex.Message.IndexOf ("'from'") != -1, "#B6: " + ex.Message);
+					Assert.AreEqual (156, ex.Number, "#B7");
+				}
 				Assert.AreEqual ((byte) 1, ex.State, "#B8");
 			}
 
@@ -595,7 +608,10 @@ namespace MonoTests.System.Data.SqlClient
 				Assert.IsNotNull (ex.Message, "#A5");
 				Assert.IsTrue (ex.Message.IndexOf ("'id1'") != -1, "#A6:" + ex.Message);
 				Assert.AreEqual (207, ex.Number, "#A7");
-				Assert.AreEqual ((byte) 1, ex.State, "#A8");
+				if (ClientVersion == 7)
+					Assert.AreEqual ((byte) 3, ex.State, "#A8");
+				else
+					Assert.AreEqual ((byte) 1, ex.State, "#A8");
 			}
 
 			// ensure connection is not closed after error
@@ -1589,16 +1605,23 @@ namespace MonoTests.System.Data.SqlClient
 					cmd.ExecuteNonQuery ();
 					Assert.Fail ("#B1");
 				} catch (SqlException ex) {
-					// Procedure or Function '#sp_temp_insert_employee'
-					// expects parameter '@fname', which was not supplied
 					Assert.AreEqual (typeof (SqlException), ex.GetType (), "#B2");
 					Assert.AreEqual ((byte) 16, ex.Class, "#B3");
 					Assert.IsNull (ex.InnerException, "#B4");
 					Assert.IsNotNull (ex.Message, "#B5");
 					Assert.IsTrue (ex.Message.IndexOf ("#sp_temp_insert_employee") != -1, "#B6:"+ ex.Message);
-					Assert.IsTrue (ex.Message.IndexOf ("'@fname'") != -1, "#B7:" + ex.Message);
-					Assert.AreEqual (201, ex.Number, "#B8");
-					Assert.AreEqual ((byte) 4, ex.State, "#B9");
+					if (ClientVersion == 7) {
+						// fname is not a parameter for procedure #sp_temp_insert_employee
+						Assert.IsTrue (ex.Message.IndexOf ("fname") != -1, "#B7: " + ex.Message);
+						Assert.AreEqual (8145, ex.Number, "#B8");
+						Assert.AreEqual ((byte) 2, ex.State, "#B9");
+					} else {
+						// Procedure or Function '#sp_temp_insert_employee' expects
+						// parameter '@fname', which was not supplied
+						Assert.IsTrue (ex.Message.IndexOf ("'@fname'") != -1, "#B7: " + ex.Message);
+						Assert.AreEqual (201, ex.Number, "#B8");
+						Assert.AreEqual ((byte) 4, ex.State, "#B9");
+					}
 				}
 #endif
 			} finally {
@@ -1615,6 +1638,9 @@ namespace MonoTests.System.Data.SqlClient
 		[Test] // bug #319598
 		public void LongQueryTest ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Hangs on SQL Server 7.0");
+
 			SqlConnection conn = new SqlConnection (
 							connectionString + ";Pooling=false");
 			using (conn) {
@@ -1629,6 +1655,9 @@ namespace MonoTests.System.Data.SqlClient
 		[Test] // bug #319598
 		public void LongStoredProcTest ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Hangs on SQL Server 7.0");
+
 			SqlConnection conn = new SqlConnection (
 							connectionString + ";Pooling=false");
 			using (conn) {
@@ -2533,9 +2562,14 @@ namespace MonoTests.System.Data.SqlClient
 				Assert.AreEqual ((byte) 15, ex.Class, "#B3");
 				Assert.IsNull (ex.InnerException, "#B4");
 				Assert.IsNotNull (ex.Message, "#B5");
-				Assert.IsTrue (ex.Message.IndexOf ("'NewId'") != -1, "#B6:" + ex.Message);
-				Assert.IsTrue (ex.Message.IndexOf ("\"@Id\"") != -1, "#B7:" + ex.Message);
-				Assert.AreEqual (102, ex.Number, "#B8");
+				Assert.IsTrue (ex.Message.IndexOf ("'NewId'") != -1, "#B6: " + ex.Message);
+				if (ClientVersion == 7) {
+					Assert.IsTrue (ex.Message.IndexOf ("'@Id'") != -1, "#B7: " + ex.Message);
+					Assert.AreEqual (170, ex.Number, "#B8");
+				} else {
+					Assert.IsTrue (ex.Message.IndexOf ("\"@Id\"") != -1, "#B7: " + ex.Message);
+					Assert.AreEqual (102, ex.Number, "#B8");
+				}
 				Assert.AreEqual ((byte) 1, ex.State, "#B9");
 			}
 #endif
@@ -2881,6 +2915,12 @@ namespace MonoTests.System.Data.SqlClient
 			}
 		}
 
+		int ClientVersion {
+			get {
+				return (engine.ClientVersion);
+			}
+		}
+
 		private enum Status
 		{
 			OK = 0,

+ 13 - 2
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs

@@ -45,12 +45,14 @@ namespace MonoTests.System.Data
 		SqlConnection conn;
 		String connectionString;
 		ArrayList events;
+		EngineConfig engine;
 
 		[SetUp]
 		public void SetUp ()
 		{
 			events = new ArrayList ();
 			connectionString = ConnectionManager.Singleton.ConnectionString;
+			engine = ConnectionManager.Singleton.Engine;
 		}
 
 		[TearDown]
@@ -165,7 +167,7 @@ namespace MonoTests.System.Data
 				Assert.AreEqual ((byte) 11, ex.Class, "#3");
 				Assert.IsNull (ex.InnerException, "#4");
 				Assert.IsNotNull (ex.Message, "#5");
-				Assert.IsTrue (ex.Message.IndexOf ("\"invalidDB\"") != -1, "#6");
+				Assert.IsTrue (ex.Message.IndexOf ("invalidDB") != -1, "#6: " + ex.Message);
 				Assert.AreEqual (4060, ex.Number, "#7");
 				Assert.AreEqual ((byte) 1, ex.State, "#8");
 			} finally {
@@ -703,7 +705,10 @@ namespace MonoTests.System.Data
 			Assert.AreEqual ("master", conn.Database, "#1");
 
 			// ensure we're really in the expected database
-			cmd.CommandText = "SELECT name FROM sys.databases WHERE name = 'master'";
+			if (ClientVersion == 7)
+				cmd.CommandText = "SELECT name FROM sysdatabases WHERE name = 'master'";
+			else
+				cmd.CommandText = "SELECT name FROM sys.databases WHERE name = 'master'";
 			using (SqlDataReader dr = cmd.ExecuteReader ()) {
 				Assert.IsTrue (dr.Read (), "#2");
 			}
@@ -824,6 +829,12 @@ namespace MonoTests.System.Data
 			return connection_count;
 		}
 #endif
+
+		int ClientVersion {
+			get {
+				return (engine.ClientVersion);
+			}
+		}
 	}
 
 #if NET_2_0

+ 298 - 88
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs

@@ -40,15 +40,189 @@ using NUnit.Framework;
 
 namespace MonoTests.System.Data.SqlClient
 {
-
 	[TestFixture]
 	[Category ("sqlserver")]
 	public class SqlDataAdapterTest
 	{
-		SqlDataAdapter adapter = null; 
-		DataSet data = null ;
-		string  connectionString = ConnectionManager.Singleton.ConnectionString;
-		SqlConnection conn = null; 
+		SqlDataAdapter adapter;
+		SqlDataReader dr;
+		DataSet data;
+		string connectionString = ConnectionManager.Singleton.ConnectionString;
+		SqlConnection conn;
+		EngineConfig engine;
+
+		[SetUp]
+		public void SetUp ()
+		{
+			engine = ConnectionManager.Singleton.Engine;
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			if (adapter != null) {
+				adapter.Dispose ();
+				adapter = null;
+			}
+
+			if (dr != null) {
+				dr.Close ();
+				dr = null;
+			}
+
+			if (conn != null) {
+				conn.Close ();
+				conn = null;
+			}
+		}
+
+		[Test]
+		public void Update_DeleteRow ()
+		{
+			conn = new SqlConnection (ConnectionManager.Singleton.ConnectionString);
+			conn.Open ();
+
+			DataTable dt = new DataTable ();
+			adapter = new SqlDataAdapter ("SELECT * FROM employee", conn);
+			SqlCommandBuilder builder = new SqlCommandBuilder (adapter);
+			adapter.DeleteCommand = builder.GetDeleteCommand ();
+			adapter.Fill (dt);
+
+			DateTime now = DateTime.Now;
+
+			DateTime doj = new DateTime (now.Year, now.Month, now.Day, now.Hour,
+				now.Minute, now.Second);
+
+			DateTime dob = new DateTime (now.Year, now.Month, now.Day, now.Hour,
+				now.Minute, now.Second);
+			dob.Subtract (new TimeSpan (20 * 365, 0, 0, 0));
+
+			try {
+				DataRow newRow = dt.NewRow ();
+				newRow ["id"] = 6002;
+				newRow ["fname"] = "boston";
+				newRow ["dob"] = dob;
+				newRow ["doj"] = doj;
+				newRow ["email"] = "[email protected]";
+				dt.Rows.Add (newRow);
+				adapter.Update (dt);
+
+				foreach (DataRow row in dt.Rows)
+					if (((int) row ["id"]) == 6002)
+						row.Delete ();
+				adapter.Update (dt);
+
+				SqlCommand cmd = conn.CreateCommand ();
+				cmd.CommandText = "SELECT id, fname, lname, dob, doj, email FROM employee WHERE id = 6002";
+				dr = cmd.ExecuteReader ();
+				Assert.IsFalse (dr.Read ());
+				dr.Close ();
+			} finally {
+				DBHelper.ExecuteSimpleSP (conn, "sp_clean_employee_table");
+			}
+		}
+
+		[Test]
+		public void Update_InsertRow ()
+		{
+			conn = new SqlConnection (ConnectionManager.Singleton.ConnectionString);
+			conn.Open ();
+
+			DataTable dt = new DataTable ();
+			adapter = new SqlDataAdapter ("SELECT * FROM employee", conn);
+
+			SqlCommandBuilder builder = new SqlCommandBuilder (adapter);
+			adapter.InsertCommand = builder.GetInsertCommand ();
+			adapter.Fill (dt);
+
+			DateTime now = DateTime.Now;
+
+			DateTime doj = new DateTime (now.Year, now.Month, now.Day, now.Hour,
+				now.Minute, now.Second);
+
+			DateTime dob = new DateTime (now.Year, now.Month, now.Day, now.Hour,
+				now.Minute, now.Second);
+			dob.Subtract (new TimeSpan (20 * 365, 0, 0, 0));
+
+			try {
+				DataRow newRow = dt.NewRow ();
+				newRow ["id"] = 6002;
+				newRow ["fname"] = "boston";
+				newRow ["dob"] = dob;
+				newRow ["doj"] = doj;
+				newRow ["email"] = "[email protected]";
+				dt.Rows.Add (newRow);
+				adapter.Update (dt);
+
+				SqlCommand cmd = conn.CreateCommand ();
+				cmd.CommandText = "SELECT id, fname, lname, dob, doj, email FROM employee WHERE id = 6002";
+				dr = cmd.ExecuteReader ();
+				Assert.IsTrue (dr.Read (), "#A1");
+				Assert.AreEqual (6002, dr.GetValue (0), "#A2");
+				Assert.AreEqual ("boston", dr.GetValue (1), "#A3");
+				Assert.AreEqual (DBNull.Value, dr.GetValue (2), "#A4");
+				Assert.AreEqual (dob, dr.GetValue (3), "#A5");
+				Assert.AreEqual (doj, dr.GetValue (4), "#A6");
+				Assert.AreEqual ("[email protected]", dr.GetValue (5), "#A7");
+				Assert.IsFalse (dr.Read (), "#A8");
+				dr.Close ();
+			} finally {
+				DBHelper.ExecuteSimpleSP (conn, "sp_clean_employee_table");
+			}
+		}
+
+		[Test]
+		public void Update_UpdateRow ()
+		{
+			conn = new SqlConnection (ConnectionManager.Singleton.ConnectionString);
+			conn.Open ();
+
+			DataTable dt = new DataTable ();
+			adapter = new SqlDataAdapter ("SELECT * FROM employee", conn);
+			SqlCommandBuilder builder = new SqlCommandBuilder (adapter);
+			adapter.UpdateCommand = builder.GetUpdateCommand ();
+			adapter.Fill (dt);
+
+			DateTime now = DateTime.Now;
+
+			DateTime doj = new DateTime (now.Year, now.Month, now.Day, now.Hour,
+				now.Minute, now.Second);
+
+			DateTime dob = new DateTime (now.Year, now.Month, now.Day, now.Hour,
+				now.Minute, now.Second);
+			dob.Subtract (new TimeSpan (20 * 365, 0, 0, 0));
+
+			try {
+				DataRow newRow = dt.NewRow ();
+				newRow ["id"] = 6002;
+				newRow ["fname"] = "boston";
+				newRow ["dob"] = dob;
+				newRow ["doj"] = doj;
+				newRow ["email"] = "[email protected]";
+				dt.Rows.Add (newRow);
+				adapter.Update (dt);
+
+				foreach (DataRow row in dt.Rows)
+					if (((int) row ["id"]) == 6002)
+						row ["lname"] = "de Icaza";
+				adapter.Update (dt);
+
+				SqlCommand cmd = conn.CreateCommand ();
+				cmd.CommandText = "SELECT id, fname, lname, dob, doj, email FROM employee WHERE id = 6002";
+				dr = cmd.ExecuteReader ();
+				Assert.IsTrue (dr.Read (), "#A1");
+				Assert.AreEqual (6002, dr.GetValue (0), "#A2");
+				Assert.AreEqual ("boston", dr.GetValue (1), "#A3");
+				Assert.AreEqual ("de Icaza", dr.GetValue (2), "#A4");
+				Assert.AreEqual (dob, dr.GetValue (3), "#A5");
+				Assert.AreEqual (doj, dr.GetValue (4), "#A6");
+				Assert.AreEqual ("[email protected]", dr.GetValue (5), "#A7");
+				Assert.IsFalse (dr.Read (), "#A8");
+				dr.Close ();
+			} finally {
+				DBHelper.ExecuteSimpleSP (conn, "sp_clean_employee_table");
+			}
+		}
 
 		/**
 		   The below test will not run everytime, since the region id column is unique
@@ -131,7 +305,7 @@ namespace MonoTests.System.Data.SqlClient
 		   NULL		bbbbbb
 		**/
 		[Test]
-		public void NullGuidTest() 
+		public void NullGuidTest()
 		{
 			conn = (SqlConnection) ConnectionManager.Singleton.Connection;
 			try {
@@ -151,7 +325,6 @@ namespace MonoTests.System.Data.SqlClient
 			}
 			// the bug 68804 - is that the fill hangs!
 			Assert.AreEqual("Done","Done");
-					
 		}
 
 		[Test]
@@ -209,6 +382,7 @@ namespace MonoTests.System.Data.SqlClient
 				adapter.SelectCommand.Connection.ConnectionString,
 				"#11  ");
 		}
+
 		[Test]
 		public void Fill_Test_ConnState ()
 		{
@@ -252,12 +426,12 @@ namespace MonoTests.System.Data.SqlClient
 		{
 			//Check if a table is created for each resultset 
 			String batchQuery = "Select id,type_bit,type_int from numeric_family;";
-			batchQuery += "Select type_bit,type_bigint from numeric_family";
+			batchQuery += "Select type_bit from numeric_family";
 			adapter = new SqlDataAdapter (batchQuery, connectionString);
 			data = new DataSet ("test1");
 			adapter.Fill (data);
 			Assert.AreEqual (2, data.Tables.Count,"#1 2 Table shud be created");
-				
+
 			//Check if Table and Col are named correctly for unnamed columns 
 			string query = "Select 10,20 from numeric_family;" ;
 			query += "Select 10,20 from numeric_family";
@@ -350,7 +524,7 @@ namespace MonoTests.System.Data.SqlClient
 
 			// Test if rows are appended  and not merged 
 			// when primary key is not returned in the result-set
-			string query = "Select type_int,type_bigint from numeric_family";
+			string query = "Select type_int from numeric_family";
 			adapter.SelectCommand.CommandText = query;
 			data = new DataSet ("test2");
 			adapter.Fill (data);
@@ -439,42 +613,74 @@ namespace MonoTests.System.Data.SqlClient
 		[Test]
 		public void Fill_Test_FillErrorTest ()
 		{
-			string query = "select type_bigint from numeric_family where id=1 or id=4 ";
+			string query = "select type_int from numeric_family where id=1 or id=4 ";
 
 			DataSet ds = new DataSet ();
 			DataTable table = ds.Tables.Add ("test");
-			table.Columns.Add ("col", typeof (int));
+			table.Columns.Add ("col", typeof (short));
 
 			adapter = new SqlDataAdapter (query, connectionString);
 			DataTableMapping mapping = adapter.TableMappings.Add ("numeric_family", "test");
-			mapping.ColumnMappings.Add ("type_bigint", "col");
+			mapping.ColumnMappings.Add ("type_int", "col");
 
-			int count = 0;
 			try {
-				count = adapter.Fill (ds, "numeric_family");
-				Assert.Fail ("#1 Overflow exception must be thrown");
-			}catch (Exception e) {
-				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#1a Expected exception is OverflowException");
+				adapter.Fill (ds, "numeric_family");
+				Assert.Fail ("#A1");
+			} catch (OverflowException) {
+			} catch (ArgumentException ex) {
+				// System.OverflowException: Value was either too large or too
+				// small for an Int16
+				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
+#if NET_2_0
+				Assert.IsNotNull (ex.InnerException, "#A3");
+#else
+				Assert.IsNull (ex.InnerException, "#A3");
+#endif
+				Assert.IsNotNull (ex.Message, "#A4");
+				Assert.IsNull (ex.ParamName, "#A5");
+
+#if NET_2_0
+				OverflowException inner = ex.InnerException as OverflowException;
+				Assert.IsNotNull (inner, "#A6");
+				Assert.AreEqual (typeof (OverflowException), inner.GetType (), "#A7");
+				Assert.IsNull (inner.InnerException, "#A8");
+				Assert.IsNotNull (inner.Message, "#A9");
+#endif
 			}
-			Assert.AreEqual (0, ds.Tables [0].Rows.Count, "#2");
-			Assert.AreEqual (0, count, "#3");
+			Assert.AreEqual (0, ds.Tables [0].Rows.Count, "#A10");
 
 			adapter.FillError += new FillErrorEventHandler (ErrorHandler);
 			FillErrorContinue = false;
 			try {
-				count = adapter.Fill (ds, "numeric_family");
-				Assert.Fail ("#4 Overflow exception must be thrown");
-			}catch (Exception e) {
-				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#4 Overflow exception must be thrown");
+				adapter.Fill (ds, "numeric_family");
+				Assert.Fail ("#B1");
+			} catch (OverflowException) {
+			} catch (ArgumentException ex) {
+				// System.OverflowException: Value was either too large or too
+				// small for an Int16
+				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
+#if NET_2_0
+				Assert.IsNotNull (ex.InnerException, "#B3");
+#else
+				Assert.IsNull (ex.InnerException, "#B3");
+#endif
+				Assert.IsNotNull (ex.Message, "#B4");
+				Assert.IsNull (ex.ParamName, "#B5");
+
+#if NET_2_0
+				OverflowException inner = ex.InnerException as OverflowException;
+				Assert.IsNotNull (inner, "#B6");
+				Assert.AreEqual (typeof (OverflowException), inner.GetType (), "#B7");
+				Assert.IsNull (inner.InnerException, "#B8");
+				Assert.IsNotNull (inner.Message, "#B9");
+#endif
 			}
-			Assert.AreEqual (0, ds.Tables [0].Rows.Count, "#5");
-			Assert.AreEqual (0, count, "#6");
+			Assert.AreEqual (0, ds.Tables [0].Rows.Count, "#B10");
 
 			FillErrorContinue = true;
-			count = adapter.Fill (ds, "numeric_family");
-			// 1 row shud be filled
-			Assert.AreEqual (1, ds.Tables [0].Rows.Count, "#7");
-			Assert.AreEqual (1, count, "#8");
+			int count = adapter.Fill (ds, "numeric_family");
+			Assert.AreEqual (1, ds.Tables [0].Rows.Count, "#C1");
+			Assert.AreEqual (1, count, "#C2");
 		}
 
 		void ErrorHandler (object sender, FillErrorEventArgs args)
@@ -503,7 +709,7 @@ namespace MonoTests.System.Data.SqlClient
 		[Test]
 		public void FillSchemaTest ()
 		{
-			string query = ""; 	
+			string query;
 
 			// Test if connection is closed if excepton occurs during fill schema 
 			query = "select * from invalid_table"; 
@@ -511,9 +717,8 @@ namespace MonoTests.System.Data.SqlClient
 			data = new DataSet ("test");
 			try {
 				adapter.FillSchema (data , SchemaType.Source);
-			}catch {
-				if ( adapter.SelectCommand.Connection.State != ConnectionState.Closed)
-				{
+			} catch {
+				if (adapter.SelectCommand.Connection.State != ConnectionState.Closed) {
 					Assert.Fail ("#0 Conn shud be closed if exception occurs");
 					adapter.SelectCommand.Connection.Close();
 				}
@@ -588,7 +793,7 @@ namespace MonoTests.System.Data.SqlClient
 				Console.WriteLine ("Table == {0}",tab.TableName);
 				foreach (DataColumn col in tab.Columns)
 					Console.WriteLine (" Col = {0} " , col.ColumnName);
-			}			
+			}
 			*/
 		}
 
@@ -624,24 +829,25 @@ namespace MonoTests.System.Data.SqlClient
 			try {
 				adapter.Fill (data);
 				Assert.Fail ("#8 Exception shud be thrown: Schema Mismatch");
-			}catch (AssertionException e) {
-				throw e;
-			}catch (Exception e){
-				Assert.AreEqual (typeof(InvalidOperationException), e.GetType(),
-					"#9 Incorrect Exception : "+e); 
+			} catch (InvalidOperationException ex) {
+				Assert.AreEqual (typeof(InvalidOperationException), ex.GetType(),
+					"#9");
 			}
-		
-			// Test for invalid MissingSchema Value 	
+
+			// Test for invalid MissingSchema Value
 			try {
 				adapter.MissingSchemaAction = (MissingSchemaAction)(-5000);
 				Assert.Fail ("#10 Exception shud be thrown: Invalid Value");
-			}catch (AssertionException e){
-				throw e;
-			}catch (Exception e){
-				Assert.AreEqual (typeof(ArgumentException), e.GetType(),
-					"#11 Incorrect Exception : " +e);
+#if NET_2_0
+			} catch (ArgumentOutOfRangeException ex) {
+				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#11");
 			}
-			
+#else
+			} catch (ArgumentException ex) {
+				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#11");
+			}
+#endif
+
 			// Tests if Data is filled correctly if schema is defined 
 			// manually and MissingSchemaAction.Error is set 
 			adapter.MissingSchemaAction = MissingSchemaAction.Error;
@@ -650,13 +856,9 @@ namespace MonoTests.System.Data.SqlClient
 			table.Columns.Add ("id");
 			table.Columns.Add ("type_bit");
 			table.Columns.Add ("type_int");
-			try {
-				adapter.Fill (data);
-				Assert.AreEqual (1, data.Tables.Count, "#12");
-				Assert.AreEqual (4, data.Tables[0].Rows.Count, "#13");
-			}catch (Exception e) {
-				Assert.Fail ("#12 Unexpected Exception : " + e);
-			}
+			adapter.Fill (data);
+			Assert.AreEqual (1, data.Tables.Count, "#12");
+			Assert.AreEqual (4, data.Tables[0].Rows.Count, "#13");
 		}
 		
 		[Test]
@@ -684,23 +886,25 @@ namespace MonoTests.System.Data.SqlClient
 			try {
 				adapter.Fill (data);
 				Assert.Fail ("#5 Exception shud be thrown : Mapping is missing");
-			}catch (AssertionException e){
-				throw e;
-			}catch (Exception e) {
-				Assert.AreEqual (typeof(InvalidOperationException), e.GetType(),
-					"#6 Incorrect Exception : " + e);
+			} catch (InvalidOperationException ex) {
+				Assert.AreEqual (typeof(InvalidOperationException), ex.GetType(),
+					"#6");
 			}
 
 			try {
 				adapter.MissingMappingAction = (MissingMappingAction)(-5000);
 				Assert.Fail ("#7 Exception shud be thrown : Invalid Value");
-			}catch (AssertionException e){
-				throw e;
-			}catch (Exception e){
-				Assert.AreEqual (typeof(ArgumentException), e.GetType(),
-					"#8 Incorrect Exception : " +e); 
+#if NET_2_0
+			} catch (ArgumentOutOfRangeException ex) {
+				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (),
+					"#8");
 			}
-		
+#else
+			} catch (ArgumentException ex) {
+				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#8");
+			}
+#endif
+
 			// Test if mapping the column and table names works correctly	
 			adapter.MissingMappingAction = MissingMappingAction.Error;
 			data.Reset ();
@@ -722,12 +926,10 @@ namespace MonoTests.System.Data.SqlClient
 				"#10 Data shud be populated if mapping is correct");
 		}
 
-		// Test case for bug #76433 
-		[Test]
+		[Test] // bug #76433
 		public void FillSchema_ValuesTest()
 		{
-			SqlConnection conn = new SqlConnection(connectionString);
-			using (conn) {
+			using (SqlConnection conn = new SqlConnection(connectionString)) {
 				conn.Open();
 				IDbCommand command = conn.CreateCommand();
 
@@ -741,12 +943,10 @@ namespace MonoTests.System.Data.SqlClient
 				DataSet dataSet = new DataSet();
 				string selectString = "SELECT * FROM #tmp_TestTable";
 				IDbDataAdapter dataAdapter = new SqlDataAdapter (
-									selectString,conn);
+									selectString, conn);
 				dataAdapter.FillSchema(dataSet, SchemaType.Mapped);
 
 				Assert.AreEqual (1, dataSet.Tables.Count, "#1");
-
-				//DataColumn col = dataSet.Tables[0].Columns[0]; 
 				Assert.IsFalse (dataSet.Tables[0].Columns[0].AllowDBNull,"#2");
 				Assert.IsTrue (dataSet.Tables[0].Columns[1].AllowDBNull,"#3");
 			}
@@ -755,8 +955,7 @@ namespace MonoTests.System.Data.SqlClient
 		[Test]
 		public void Fill_CheckSchema ()
 		{
-			SqlConnection conn = new SqlConnection(connectionString);
-			using (conn) {
+			using (SqlConnection conn = new SqlConnection(connectionString)) {
 				conn.Open();
 
 				IDbCommand command = conn.CreateCommand();
@@ -773,22 +972,28 @@ namespace MonoTests.System.Data.SqlClient
 				IDbDataAdapter dataAdapter = new SqlDataAdapter (
 									selectString,conn);
 				dataAdapter.Fill (dataSet);
-				Assert.IsTrue (dataSet.Tables[0].Columns[1].AllowDBNull, "#1");
-				Assert.AreEqual (0, dataSet.Tables[0].PrimaryKey.Length, "#2");
+				Assert.AreEqual (1, dataSet.Tables.Count, "#A1");
+				Assert.AreEqual (2, dataSet.Tables [0].Columns.Count, "#A2");
+				Assert.IsTrue (dataSet.Tables [0].Columns [1].AllowDBNull, "#A3");
+				Assert.AreEqual (0, dataSet.Tables [0].PrimaryKey.Length, "#A4");
 
 				dataSet.Reset ();
-				dataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey ;
+				dataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
 				dataAdapter.Fill (dataSet);
-				Assert.IsFalse (dataSet.Tables[0].Columns[1].AllowDBNull, "#3");
-				Assert.AreEqual (1, dataSet.Tables[0].PrimaryKey.Length, "#4");
+				Assert.AreEqual (1, dataSet.Tables.Count, "#B1");
+				Assert.AreEqual (2, dataSet.Tables [0].Columns.Count, "#B2");
+				Assert.IsFalse (dataSet.Tables [0].Columns [1].AllowDBNull, "#B3");
+				if (ClientVersion == 7)
+					Assert.AreEqual (0, dataSet.Tables [0].PrimaryKey.Length, "#B4");
+				else
+					Assert.AreEqual (1, dataSet.Tables [0].PrimaryKey.Length, "#B4");
 			}
 		}
 
 		[Test]
 		public void FillSchema_CheckSchema ()
 		{
-			SqlConnection conn = new SqlConnection(connectionString);
-			using (conn) {
+			using (SqlConnection conn = new SqlConnection(connectionString)) {
 				conn.Open();
 
 				IDbCommand command = conn.CreateCommand();
@@ -823,9 +1028,8 @@ namespace MonoTests.System.Data.SqlClient
 				try {
 					dataAdapter.FillSchema (dataSet, SchemaType.Mapped);
 					Assert.Fail ("#4 Error should be thrown");
-				} catch (Exception e) {
-					Assert.AreEqual (typeof (InvalidOperationException), e.GetType (),
-							 "#4 InvalidOperationException must be thrown");
+				} catch (InvalidOperationException ex) {
+					Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#4");
 				}
 			}
 		}
@@ -899,9 +1103,15 @@ namespace MonoTests.System.Data.SqlClient
 		public void UpdateBatchSizeArgumentOutOfRangeTest ()
 		{
 			adapter = new SqlDataAdapter();
-			adapter.UpdateBatchSize = -2;	
+			adapter.UpdateBatchSize = -2;
 		}
 #endif
+
+		int ClientVersion {
+			get {
+				return (engine.ClientVersion);
+			}
+		}
 	}
 
 #if NET_2_0
@@ -909,7 +1119,7 @@ namespace MonoTests.System.Data.SqlClient
 	[Category ("sqlserver")]
 	public class SqlDataAdapterInheritTest : DbDataAdapter
 	{
-		SqlConnection conn = null; 
+		SqlConnection conn = null;
 
 		[Test]
 		public void FillDataAdapterTest () {
@@ -923,7 +1133,7 @@ namespace MonoTests.System.Data.SqlClient
 				SelectCommand = command;
 				Fill (dt, command.ExecuteReader ());
 				Assert.AreEqual (4, dt.Rows.Count, "#1");
-				Assert.AreEqual (6, dt.Columns.Count, "#1");
+				Assert.AreEqual (6, dt.Columns.Count, "#2");
 			} finally {
 				DBHelper.ExecuteSimpleSP (conn, "sp_clean_employee_table");
 				ConnectionManager.Singleton.CloseConnection ();

+ 34 - 4
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterTest.cs

@@ -44,12 +44,14 @@ namespace MonoTests.System.Data.SqlClient
 		SqlConnection conn;
 		SqlCommand cmd;
 		SqlDataReader rdr;
+		EngineConfig engine;
 
 		[SetUp]
 		public void SetUp ()
 		{
 			conn = (SqlConnection) ConnectionManager.Singleton.Connection;
 			ConnectionManager.Singleton.OpenConnection ();
+			engine = ConnectionManager.Singleton.Engine;
 		}
 
 		[TearDown]
@@ -65,6 +67,9 @@ namespace MonoTests.System.Data.SqlClient
 		[Test] // bug #324840
 		public void ParameterSizeTest ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Hangs on SQL Server 7.0");
+
 			string longstring = new String('x', 20480);
 			SqlParameter prm;
 			cmd = new SqlCommand ("create table #text1 (ID int not null, Val1 ntext)", conn);
@@ -222,8 +227,11 @@ namespace MonoTests.System.Data.SqlClient
 		}
 
 		[Test] // bug #382589
-		public void DecimalMaxAsParamValueTest () 
+		public void DecimalMaxAsParamValueTest ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Maximum precision is 28.");
+
 			string create_sp = "CREATE PROCEDURE #sp_bug382539 (@decmax decimal(29,0) OUT)"
 				+ "AS " + Environment.NewLine
 				+ "BEGIN" + Environment.NewLine
@@ -246,8 +254,11 @@ namespace MonoTests.System.Data.SqlClient
 		}
 
 		[Test] // bug #382589
-		public void DecimalMinAsParamValueTest () 
+		public void DecimalMinAsParamValueTest ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Maximum precision is 28.");
+
 			string create_sp = "CREATE PROCEDURE #sp_bug382539 (@decmax decimal(29,0) OUT)"
 				+ "AS " + Environment.NewLine
 				+ "BEGIN" + Environment.NewLine
@@ -270,8 +281,11 @@ namespace MonoTests.System.Data.SqlClient
 		}
 
 		[Test] // bug #382589
-		public void DecimalMaxAsParamValueExceptionTest () 
+		public void DecimalMaxAsParamValueExceptionTest ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Maximum precision is 28.");
+
 			string create_sp = "CREATE PROCEDURE #sp_bug382539 (@decmax decimal(29,10) OUT)"
 				+ "AS " + Environment.NewLine
 				+ "BEGIN" + Environment.NewLine
@@ -302,8 +316,11 @@ namespace MonoTests.System.Data.SqlClient
 		}
 
 		[Test] // bug# 382589
-		public void DecimalMinAsParamValueExceptionTest () 
+		public void DecimalMinAsParamValueExceptionTest ()
 		{
+			if (ClientVersion == 7)
+				Assert.Ignore ("Maximum precision is 28.");
+
 			string create_sp = "CREATE PROCEDURE #sp_bug382539 (@decmax decimal(29,10) OUT)"
 				+ "AS " + Environment.NewLine
 				+ "BEGIN" + Environment.NewLine
@@ -363,6 +380,7 @@ namespace MonoTests.System.Data.SqlClient
 				cmd.ExecuteNonQuery ();
 				Assert.Fail ("#B1");
 			} catch (FormatException ex) {
+#if NET_2_0
 				// Failed to convert parameter value from a String to a Int32
 				Assert.AreEqual (typeof (FormatException), ex.GetType (), "#B2");
 				Assert.IsNotNull (ex.Message, "#B3");
@@ -375,6 +393,18 @@ namespace MonoTests.System.Data.SqlClient
 				Assert.AreEqual (typeof (FormatException), inner.GetType (), "#B7");
 				Assert.IsNull (inner.InnerException, "#B8");
 				Assert.IsNotNull (inner.Message, "#B9");
+#else
+				// Input string was not in a correct format
+				Assert.AreEqual (typeof (FormatException), ex.GetType (), "#B2");
+				Assert.IsNull (ex.InnerException, "#B3");
+				Assert.IsNotNull (ex.Message, "#B4");
+#endif
+			}
+		}
+
+		int ClientVersion {
+			get {
+				return (engine.ClientVersion);
 			}
 		}
 	}

+ 12 - 1
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlTransactionTest.cs

@@ -44,11 +44,13 @@ namespace MonoTests.System.Data.SqlClient
 		SqlConnection conn;
 		SqlTransaction trans;
 		String connectionString;
+		EngineConfig engine;
 
 		[SetUp]
 		public void SetUp ()
 		{
 			connectionString = ConnectionManager.Singleton.ConnectionString;
+			engine = ConnectionManager.Singleton.Engine;
 		}
 
 		[TearDown]
@@ -1533,7 +1535,10 @@ namespace MonoTests.System.Data.SqlClient
 					Assert.IsNotNull (ex.Message, "#5");
 					Assert.IsTrue (ex.Message.IndexOf ("SAVE1") != -1, "#6");
 					Assert.AreEqual (6401, ex.Number, "#7");
-					Assert.AreEqual ((byte) 1, ex.State, "#8");
+					if (ClientVersion == 7)
+						Assert.AreEqual ((byte) 2, ex.State, "#8");
+					else
+						Assert.AreEqual ((byte) 1, ex.State, "#8");
 				}
 
 				trans.Commit ();
@@ -2070,6 +2075,12 @@ namespace MonoTests.System.Data.SqlClient
 			}
 		}
 
+		int ClientVersion {
+			get {
+				return (engine.ClientVersion);
+			}
+		}
+
 		static bool RunningOnMono {
 			get
 			{