2
0
Эх сурвалжийг харах

2005-09-24 Sureshkumar T <[email protected]>
In sql:

* sybase.sql: grant permissions on objects

* sqlserver.sql: change id as int. tiny int won't allow 6000 (the
tempory updatable limit).

In System.Data.SqlClient:

* SqlDataAdapterTest.cs (Fill_Test_Exceptions): passing null
dataset name throws ArgumentNullException in ms.net

* SqlConnectionTest.cs: HostName compare: convert to uppercase.

* SqlDataReaderTest.cs: remove Opening connection in few test
cases as it was done in SetUp.
- id type change changes


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

Sureshkumar T 20 жил өмнө
parent
commit
3f1e1a17dd

+ 1 - 1
mcs/class/System.Data/Test/ProviderTests/Makefile

@@ -31,7 +31,7 @@ endif
 
 test-local: run-test-db
 
-CLEAN_FILES = *.exe *.dll *.log ${LIBRARY}.config *.mdb TestResult*.xml
+CLEAN_FILES = *.exe *.dll *.log ${LIBRARY}.config *.mdb TestResult*.xml conn_string
 
 clean-local:
 	rm $(CLEAN_FILES) || :

+ 1 - 1
mcs/class/System.Data/Test/ProviderTests/ProviderIndependant/DataReaderTest.cs

@@ -114,7 +114,7 @@ namespace MonoTests.System.Data
 					if (reader.Read()) {
 						object value = reader.GetValue (0);
 						Assert.AreEqual (typeof (byte), value.GetType(), "#1 wrong type");
-						Assert.AreEqual (127, value, "#2 value is wrong");   
+						Assert.AreEqual (255, value, "#2 value is wrong");   
 					} else
 						Assert.Fail ("#3 does not have test data");
 				}

+ 1 - 1
mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcCommandTest.cs

@@ -150,7 +150,7 @@ namespace MonoTests.System.Data
 			} finally {
 				ConnectionManager.Singleton.CloseConnection ();
 			}
-                                         }
+		}
 
 	}
 }

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

@@ -1,3 +1,14 @@
+2005-09-24  Sureshkumar T  <[email protected]>
+
+	* SqlDataAdapterTest.cs (Fill_Test_Exceptions): passing null
+	dataset name throws ArgumentNullException in ms.net
+
+	* SqlConnectionTest.cs: HostName compare: convert to uppercase.
+
+	* SqlDataReaderTest.cs: remove Opening connection in few test
+	cases as it was done in SetUp.
+	- id type change changes
+
 2005-09-21 Senganal T  <[email protected]>
 
 	* SqlConnectionTest.cs: removed some hardcoded database names

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

@@ -56,7 +56,7 @@ namespace MonoTests.System.Data
 
 				SqlCommandBuilder cb = new SqlCommandBuilder (da);
 				SqlCommand cmd = cb.GetInsertCommand ();
-				Assert.AreEqual ("INSERT INTO employee (id, fname) VALUES (?, ?)",
+				Assert.AreEqual ("INSERT INTO employee (id, fname) VALUES (@p1, @p2)",
 						cmd.CommandText, "#2");
 			} finally {
 				ConnectionManager.Singleton.CloseConnection ();
@@ -77,7 +77,7 @@ namespace MonoTests.System.Data
 
 				SqlCommandBuilder cb = new SqlCommandBuilder (da);
 				SqlCommand cmd = cb.GetInsertCommand ();
-				Assert.AreEqual ("INSERT INTO employee (id, fname) VALUES (?, ?)",
+				Assert.AreEqual ("INSERT INTO employee (id, fname) VALUES (@p1, @p2)",
 						cmd.CommandText, "#2");
 			} finally {
 				ConnectionManager.Singleton.CloseConnection ();
@@ -97,7 +97,7 @@ namespace MonoTests.System.Data
 
 				SqlCommandBuilder cb = new SqlCommandBuilder (da);
 				SqlCommand cmd = cb.GetUpdateCommand ();
-				Assert.AreEqual ("UPDATE employee SET id = ?, fname = ? WHERE ((id = ?) AND ((? = 1 AND age IS NULL) OR (fname = ?)))",
+				Assert.AreEqual ("UPDATE employee SET id = @p1, fname = @p2 WHERE ((id = @p3) AND ((@p4 = 1 AND age IS NULL) OR (fname = @p5)))",
 						cmd.CommandText, "#2");
 				Assert.AreEqual (5, cmd.Parameters.Count, "#3");
 			}
@@ -141,7 +141,7 @@ namespace MonoTests.System.Data
 
 				SqlCommandBuilder cb = new SqlCommandBuilder (da);
 				SqlCommand cmd = cb.GetDeleteCommand ();
-				Assert.AreEqual ("DELETE FROM employee WHERE ((id = ?) AND ((? = 1 AND fname IS NULL) OR (fname = ?)))",
+				Assert.AreEqual ("DELETE FROM employee WHERE ((id = @p1) AND ((@p2 = 1 AND fname IS NULL) OR (fname = @p3)))",
 						cmd.CommandText, "#2");
 			} finally {
 				ConnectionManager.Singleton.CloseConnection ();

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

@@ -568,7 +568,7 @@ namespace MonoTests.System.Data.SqlClient
 				Object TestPar = "test";
 				cmd.Parameters.Add("@fname", SqlDbType.VarChar);
 				cmd.Parameters ["@fname"].Value = TestPar;
-				Assert.AreEqual(-1,cmd.ExecuteNonQuery());
+				Assert.AreEqual(1,cmd.ExecuteNonQuery());
 			} finally {
 				DBHelper.ExecuteNonQuery (conn, DROP_TMP_SP_TEMP_INSERT_PERSON);
 				DBHelper.ExecuteSimpleSP (conn, "sp_clean_person_table");

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

@@ -87,7 +87,7 @@ namespace MonoTests.System.Data
 			Assert.AreEqual ("", conn.DataSource,
 					"#4 Default DataSource should be empty");
 			Assert.AreEqual (8192, conn.PacketSize,"#5 Default Packet Size is 8192");
-			Assert.AreEqual (Dns.GetHostName(), conn.WorkstationId, 
+			Assert.AreEqual (Dns.GetHostName().ToUpper (), conn.WorkstationId.ToUpper (), 
 					"#6 Default Workstationid shud be hostname");
 			Assert.AreEqual (ConnectionState.Closed, conn.State, 
 					"#7 Connection State shud be closed by default");
@@ -253,7 +253,7 @@ namespace MonoTests.System.Data
 				"#4 Default DataSource : empty");
 			Assert.AreEqual (8192, conn.PacketSize, 
 				"#5 Default Packet Size : 8192");
-			Assert.AreEqual (Dns.GetHostName(), conn.WorkstationId, 
+			Assert.AreEqual (Dns.GetHostName().ToUpper (), conn.WorkstationId.ToUpper (), 
 				"#6 Default Workstationid : hostname");
 			Assert.AreEqual (ConnectionState.Closed, conn.State, 
 				"#7 Default State : CLOSED ");
@@ -418,7 +418,7 @@ namespace MonoTests.System.Data
 					"#11 Packetsize shud be reset to Default : 8192");
 			Assert.AreEqual (15, conn.ConnectionTimeout, 
 					"#12 ConnectionTimeour shud be reset to Default : 15");
-			Assert.AreEqual (Dns.GetHostName (), conn.WorkstationId,
+			Assert.AreEqual (Dns.GetHostName ().ToUpper (), conn.WorkstationId.ToUpper (),
 					"#13 WorkstationId shud be reset to Default : Hostname");
 			
 			// Test Argument Exception is thrown for Invalid Connection Strings

+ 2 - 0
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs

@@ -369,6 +369,8 @@ namespace MonoTests.System.Data.SqlClient
 				Assert.Fail ( "#7 Exception shud be thrown : Invalid Dataset");
 			}catch (AssertionException e){
 				throw e ;
+			}catch (ArgumentNullException) {
+		       
 			}catch (Exception e) {
 				Assert.AreEqual (typeof(SystemException), e.GetType(),
 					"#8 Incorrect Exception : " + e);

+ 45 - 47
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataReaderTest.cs

@@ -61,12 +61,43 @@ namespace MonoTests.System.Data.SqlClient
 		DataRow stringRow = null; 
 		DataRow binaryRow = null; 
 		DataRow datetimeRow = null; 
+
+		[TestFixtureSetUp]
+		public void init ()
+		{
+			conn = new SqlConnection (ConnectionManager.Singleton.ConnectionString);
+			cmd = conn.CreateCommand ();
+			
+			sqlDataset = (new DataProvider()).GetDataSet ();
+
+			numericDataTable = sqlDataset.Tables["numeric_family"];
+			stringDataTable = sqlDataset.Tables["string_family"];
+			binaryDataTable = sqlDataset.Tables["binary_family"];
+			datetimeDataTable = sqlDataset.Tables["datetime_family"];
+
+			numericRow = numericDataTable.Select ("id=1")[0];
+			stringRow = stringDataTable.Select ("id=1")[0];
+			binaryRow = binaryDataTable.Select ("id=1")[0];
+			datetimeRow = datetimeDataTable.Select ("id=1")[0];
+		}
+
+		[SetUp]
+		public void Setup ()
+		{
+			conn.Open ();
+		}
+		[TearDown]
+		public void TearDown ()
+		{
+			if (reader != null)
+				reader.Close ();
+
+			conn.Close ();
+		}
 		
 		[Test]
 		public void ReadEmptyNTextFieldTest () {
-			conn = (SqlConnection) ConnectionManager.Singleton.Connection;
 			try {
-				ConnectionManager.Singleton.OpenConnection ();
 				DBHelper.ExecuteNonQuery (conn, "create table #tmp_monotest (name ntext)");
 				DBHelper.ExecuteNonQuery (conn, "insert into #tmp_monotest values ('')");
 				
@@ -85,9 +116,7 @@ namespace MonoTests.System.Data.SqlClient
 		[Test]
 		public void ReadBingIntTest() 
 		{
-			conn = (SqlConnection) ConnectionManager.Singleton.Connection;
 			try {
-				ConnectionManager.Singleton.OpenConnection ();
 				string query = "SELECT CAST(548967465189498 AS bigint) AS Value";
 				SqlCommand cmd = new SqlCommand();
 				cmd.Connection = conn;
@@ -105,38 +134,7 @@ namespace MonoTests.System.Data.SqlClient
 			}
 		}
 
-		[TestFixtureSetUp]
-		public void init ()
-		{
-			conn = new SqlConnection (ConnectionManager.Singleton.ConnectionString);
-			cmd = conn.CreateCommand ();
-			
-			sqlDataset = (new DataProvider()).GetDataSet ();
-
-			numericDataTable = sqlDataset.Tables["numeric_family"];
-			stringDataTable = sqlDataset.Tables["string_family"];
-			binaryDataTable = sqlDataset.Tables["binary_family"];
-			datetimeDataTable = sqlDataset.Tables["datetime_family"];
-
-			numericRow = numericDataTable.Select ("id=1")[0];
-			stringRow = stringDataTable.Select ("id=1")[0];
-			binaryRow = binaryDataTable.Select ("id=1")[0];
-			datetimeRow = datetimeDataTable.Select ("id=1")[0];
-		}
-
-		[SetUp]
-		public void Setup ()
-		{
-			conn.Open ();
-		}
-		[TearDown]
-		public void TearDown ()
-		{
-			if (reader != null)
-				reader.Close ();
 
-			conn.Close ();
-		}
 
 		// This method just helps in Calling common tests among all the Get* Methods 
 		// without replicating code 
@@ -574,12 +572,12 @@ namespace MonoTests.System.Data.SqlClient
 		[Test]
 		public void GetSqlValueTest ()
 		{
-			cmd.CommandText = "Select id,null from numeric_family where id=1";
+			cmd.CommandText = "Select id, type_tinyint, null from numeric_family where id=1";
 			reader = cmd.ExecuteReader ();
 			reader.Read ();
 
-			Assert.AreEqual ((byte)1, ((SqlByte)reader.GetSqlValue(0)).Value, "#1");
-			//Assert.AreEqual (DBNull.Value, reader.GetSqlValue(1), "#2");
+			Assert.AreEqual ((byte)255, ((SqlByte) reader.GetSqlValue(1)).Value, "#1");
+			//Assert.AreEqual (DBNull.Value, reader.GetSqlValue(2), "#2");
 
 			reader.Close ();
 		}
@@ -810,13 +808,13 @@ namespace MonoTests.System.Data.SqlClient
 		[Test]
 		public void GetDataTypeNameTest ()
 		{
-			cmd.CommandText = "Select id,10,null from numeric_family where id=1";
+			cmd.CommandText = "Select id, type_tinyint, 10,null from numeric_family where id=1";
 			reader = cmd.ExecuteReader ();
 
-			Assert.AreEqual ("tinyint", reader.GetDataTypeName(0), "#1");
-			Assert.AreEqual ("int", reader.GetDataTypeName(1), "#2");
+			Assert.AreEqual ("tinyint", reader.GetDataTypeName(1), "#1");
+			Assert.AreEqual ("int", reader.GetDataTypeName(2), "#2");
 			//need check on windows 
-			Assert.AreEqual ("int", reader.GetDataTypeName(2), "#3");
+			Assert.AreEqual ("int", reader.GetDataTypeName(3), "#3");
 			try {
 				reader.GetDataTypeName (10);
 				Assert.Fail ("#4 Exception shud be thrown");
@@ -829,14 +827,14 @@ namespace MonoTests.System.Data.SqlClient
 		}
 
 		[Test]
-		public void GetFieldType ()
+		public void GetFieldTypeTest ()
 		{
-			cmd.CommandText = "Select id ,10 , null from numeric_family where id=1";
+			cmd.CommandText = "Select id , type_tinyint, 10 , null from numeric_family where id=1";
 			reader = cmd.ExecuteReader ();
 
-			Assert.AreEqual ("tinyint", reader.GetDataTypeName(0), "#1");
-			Assert.AreEqual ("int", reader.GetDataTypeName(1) , "#2");
-			Assert.AreEqual ("int", reader.GetDataTypeName(2), "#3");
+			Assert.AreEqual ("tinyint", reader.GetDataTypeName(1), "#1");
+			Assert.AreEqual ("int", reader.GetDataTypeName(2) , "#2");
+			Assert.AreEqual ("int", reader.GetDataTypeName(3), "#3");
 			try {
 				reader.GetDataTypeName (10);
 				Assert.Fail ("#4 Exception shud be thrown");

+ 7 - 0
mcs/class/System.Data/Test/ProviderTests/sql/ChangeLog

@@ -1,3 +1,10 @@
+2005-09-24  Sureshkumar T  <[email protected]>
+
+	* sybase.sql: grant permissions on objects
+
+	* sqlserver.sql: change id as int. tiny int won't allow 6000 (the
+	tempory updatable limit).
+
 2005-09-16  Senganal T  <[email protected]>
 
 	* sqlserver.sql: modified. added string_family, datetime_family,

+ 7 - 4
mcs/class/System.Data/Test/ProviderTests/sql/sqlserver.sql

@@ -3,6 +3,7 @@ if exists (select name from sysdatabases where
         drop database [mono-test];
 create database [mono-test];
 grant all privileges on [mono-test] to monotester;
+go
 
 use monotest;
 
@@ -14,7 +15,8 @@ if exists (select name from sysobjects where
 	drop table numeric_family;
 go
 
-create table numeric_family(id tinyint PRIMARY KEY NOT NULL,
+create table numeric_family(
+	id int PRIMARY KEY NOT NULL,
         type_bit bit NULL,
         type_tinyint tinyint NULL,
         type_smallint smallint NULL,
@@ -47,7 +49,7 @@ if exists (select name from sysobjects where
 go
 
 create table binary_family (
-        id tinyint PRIMARY KEY NOT NULL,
+        id int PRIMARY KEY NOT NULL,
         type_binary binary NULL,
         type_varbinary varbinary (255) NULL,
         type_blob image NULL,
@@ -78,7 +80,8 @@ if exists (select name from sysobjects where
 	drop table string_family;
 go
 
-create table string_family(id tinyint PRIMARY KEY NOT NULL,
+create table string_family(
+	id int PRIMARY KEY NOT NULL,
         type_guid uniqueidentifier NULL,
         type_char char(10) NULL,
         type_varchar varchar(10) NULL,
@@ -105,7 +108,7 @@ if exists (select name from sysobjects where
 go
 
 create table datetime_family (
-        id tinyint PRIMARY KEY NOT NULL,
+        id int PRIMARY KEY NOT NULL,
         type_smalldatetime smalldatetime NULL,
         type_datetime datetime NULL);
 

+ 8 - 0
mcs/class/System.Data/Test/ProviderTests/sql/sybase.sql

@@ -20,6 +20,8 @@ create table numeric_family (
 	type_numeric numeric (38, 0) NULL,
 	type_money money NULL,
 	type_smallmoney smallmoney NULL)
+
+grant all on numeric_family to monotester
 go
 
 insert into numeric_family values (1,1,255,32767,2147483647,9223372036854775807,1000,1000,922337203685477.5807,214748.3647)
@@ -46,6 +48,8 @@ create table binary_family (
 	type_tinyblob image NULL,
 	type_mediumblob image NULL,
 	type_longblob_image image NULL)
+
+grant all on binary_family to monotester
 go
 
 insert into binary_family values (1, convert (binary, '555555'), convert (varbinary, '0123456789012345678901234567890123456789012345678901234567890123456789'), 
@@ -98,6 +102,8 @@ begin
 end
 go
 
+grant all on sp_clean_employee_table to monotester
+go
 
 -- SP : sp_get_age
 if exists (select name from sysobjects where 
@@ -115,6 +121,8 @@ begin
 end
 go
 
+grant all on sp_get_age to monotester
+go
 
 
 -- =================================== END OBJECT EMPLOYEE ============================