Author: anagappan
Date: 2007-05-04 00:08:23 -0400 (Fri, 04 May 2007)
New Revision: 76656

Modified:
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataReaderTest.cs
   
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterTest.cs
Log:
2007-04-03  Amit Biswas <[EMAIL PROTECTED]>

        * SqlDataReaderTest.cs (GetSqlBytesTest): Test case for GetSqlBytes
        (GetProviderSpecificFieldTypeTest): Test case for 
GetProviderSpecificFieldTypeTest
        (GetProviderSpecificValueTest): Test case for 
GetProviderSpecificValueTest
        (GetProviderSpecificValueLowerBoundaryTest):
        (GetProviderSpecificValueUpperBoundaryTest):
        (GetProviderSpecificValuesTest): Test case for 
GetProviderSpecificValuesTest
        (GetProviderSpecificValuesSmallArrayTest): Test case with an array 
smaller than no. of columns
        (GetProviderSpecificValuesLargeArrayTest): Test case with an array 
larger than no. of columns
        (GetProviderSpecificValuesNullTest): Test case for null parameters

        * SqlParameterTest.cs (XmlSchemaTest): Test case for properties related 
to XML schema
        (SourceColumnNullMappingTest): Test case for SourceColumnNullMappingTest
        (ctor7Test): Test case to the constructor new in .net 2.0

        * SqlParameterTest.cs (ParameterType): Corrected a bug in the test case 
regarding
        default values of SqlDbType and DbType
        (SqlDbTypeTest): Test for SqlDbType and DbType properties
        (ResetSqlDbTypeTest): Test for ResetSqlDbType method
        (ResetDbTypeTest): Test for ResetDbType method

        * SqlParameterCollectionTest.cs (CopyToTest): Test case for CopyTo 
method



Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog  
    2007-05-04 04:07:41 UTC (rev 76655)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog  
    2007-05-04 04:08:23 UTC (rev 76656)
@@ -1,3 +1,27 @@
+2007-04-03  Amit Biswas <[EMAIL PROTECTED]>
+
+       * SqlDataReaderTest.cs (GetSqlBytesTest): Test case for GetSqlBytes
+       (GetProviderSpecificFieldTypeTest): Test case for 
GetProviderSpecificFieldTypeTest
+       (GetProviderSpecificValueTest): Test case for 
GetProviderSpecificValueTest
+       (GetProviderSpecificValueLowerBoundaryTest):
+       (GetProviderSpecificValueUpperBoundaryTest):
+       (GetProviderSpecificValuesTest): Test case for 
GetProviderSpecificValuesTest
+       (GetProviderSpecificValuesSmallArrayTest): Test case with an array 
smaller than no. of columns
+       (GetProviderSpecificValuesLargeArrayTest): Test case with an array 
larger than no. of columns
+       (GetProviderSpecificValuesNullTest): Test case for null parameters
+
+       * SqlParameterTest.cs (XmlSchemaTest): Test case for properties related 
to XML schema
+       (SourceColumnNullMappingTest): Test case for SourceColumnNullMappingTest
+       (ctor7Test): Test case to the constructor new in .net 2.0
+
+       * SqlParameterTest.cs (ParameterType): Corrected a bug in the test case 
regarding
+       default values of SqlDbType and DbType
+       (SqlDbTypeTest): Test for SqlDbType and DbType properties
+       (ResetSqlDbTypeTest): Test for ResetSqlDbType method
+       (ResetDbTypeTest): Test for ResetDbType method
+
+       * SqlParameterCollectionTest.cs (CopyToTest): Test case for CopyTo 
method
+
 2007-03-23  Nidhi Rawal <[EMAIL PROTECTED]>
 
        * SqlCommandTest.cs (BeginExecuteXmlReaderTest): Written test case for 
the method

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
   2007-05-04 04:07:41 UTC (rev 76655)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
   2007-05-04 04:08:23 UTC (rev 76656)
@@ -393,7 +393,7 @@
                                trans = conn.BeginTransaction ();
                                trans.Commit();
                                trans = conn.BeginTransaction ();
-                       }catch (Exception e) {
+                       }catch {
                                Assert.Fail ("#7 Transaction can be opened 
after a rollback/commit");
                        }finally {
                                trans.Rollback ();
@@ -483,13 +483,13 @@
                        conn = new SqlConnection (connectionString);
 
                        // Test InvalidOperation Exception is thrown if 
Connection is CLOSED
-                       try{
+                       try {
                                string s = conn.ServerVersion;
-                               Assert.Fail (
-                                       "#1 InvalidOperation Exception Must be 
thrown if conn is closed");
-                       }catch (AssertionException e){
+                               Assert.Fail ("#1 InvalidOperation Exception 
Must be thrown if conn is closed");
+                               Assert.AreEqual ("", s, "#1a Should be an empty 
string");
+                       } catch (AssertionException e){
                                throw e;
-                       }catch (Exception e){
+                       } catch (Exception e){
                                Assert.AreEqual(typeof 
(InvalidOperationException), e.GetType (),
                                        "#2 Incorrect Exception" + 
e.StackTrace);
                        }
@@ -1065,14 +1065,14 @@
                        Assert.AreEqual(true, flag, "#GS18 failed");
                }
                [Test]
-               [ExpectedException(typeof(ArgumentException))]
-               public void GetSchemaTest19()
+               [ExpectedException (typeof (ArgumentException))]
+               public void GetSchemaTest19 ()
                {
                        String [] restrictions = new String[1];
-                       DataTable tab1 = conn.GetSchema("RESTRICTIONS", 
restrictions);
+                       conn.GetSchema("RESTRICTIONS", restrictions);
                }
                [Test]
-               public void GetSchemaTest20()
+               public void GetSchemaTest20 ()
                {
                        bool flag = false;
                        DataTable tab1 = conn.GetSchema("DataTypes");
@@ -1193,11 +1193,11 @@
                        Assert.AreEqual(false, flag, "#GS24 failed");
                }
                [Test]
-               [ExpectedException(typeof(ArgumentException))]
-               public void GetSchemaTest25()
+               [ExpectedException (typeof (ArgumentException))]
+               public void GetSchemaTest25 ()
                {
-                       String [] restrictions = new String[1];
-                       DataTable tab1 = conn.GetSchema("Mono", restrictions);
+                       String [] restrictions = new String [1];
+                       conn.GetSchema ("Mono", restrictions);
                }
        }
 #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
  2007-05-04 04:07:41 UTC (rev 76655)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataAdapterTest.cs
  2007-05-04 04:08:23 UTC (rev 76656)
@@ -464,7 +464,8 @@
                        try {
                                count = adapter.Fill (ds, "numeric_family");
                                Assert.Fail ("#4 Overflow exception must be 
thrown");
-                       }catch (OverflowException e) {
+                       }catch (Exception e) {
+                               Assert.AreEqual (typeof (OverflowException), 
e.GetType (), "#4 Overflow exception must be thrown");
                        }
                        Assert.AreEqual (0, ds.Tables [0].Rows.Count, "#5");
                        Assert.AreEqual (0, count, "#6");
@@ -510,7 +511,7 @@
                        data = new DataSet ("test");
                        try {
                                adapter.FillSchema (data , SchemaType.Source);
-                       }catch (Exception e){
+                       }catch {
                                if ( adapter.SelectCommand.Connection.State != 
ConnectionState.Closed)
                                {
                                        Assert.Fail ("#0 Conn shud be closed if 
exception occurs");
@@ -745,7 +746,7 @@
 
                                Assert.AreEqual (1, dataSet.Tables.Count, "#1");
 
-                               DataColumn col = dataSet.Tables[0].Columns[0]; 
+                               //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");
                        }
@@ -822,7 +823,9 @@
                                try {
                                        dataAdapter.FillSchema (dataSet, 
SchemaType.Mapped);
                                        Assert.Fail ("#4 Error should be 
thrown");
-                               } catch (InvalidOperationException e) {
+                               } catch (Exception e) {
+                                       Assert.AreEqual (typeof 
(InvalidOperationException), e.GetType (),
+                                                        "#4 
InvalidOperationException must be thrown");
                                }
                        }
                }
@@ -867,6 +870,7 @@
                                DataColumn pcol2 = table1.Columns.Add 
("type_int", typeof (int));
 
                                table2.Constraints.Add ("fk", pcol1, ccol1);
+                               //table1.Constraints.Add ("fk1", pcol2, ccol2);
 
                                dataSet.EnforceConstraints = false;
                                dataAdapter.Fill (dataSet, "table1");

Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataReaderTest.cs
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataReaderTest.cs
   2007-05-04 04:07:41 UTC (rev 76655)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataReaderTest.cs
   2007-05-04 04:08:23 UTC (rev 76656)
@@ -1014,5 +1014,211 @@
                                datetimeDataTable);
                }
 
+#if NET_2_0
+               string connectionString = 
ConnectionManager.Singleton.ConnectionString;
+
+               //FIXME : Add more test cases
+               [Test]
+               public void GetProviderSpecificFieldTypeTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (6, rdr.FieldCount, 
"#1");
+                                       
Assert.AreEqual(typeof(SqlInt32),rdr.GetProviderSpecificFieldType(0),"#2 The 
column at index 0 must have FieldType as SqlString");
+                                       
Assert.AreEqual(typeof(SqlString),rdr.GetProviderSpecificFieldType(1),"#3 The 
column at index 1 must have FieldType as SqlString");
+                                       
Assert.AreEqual(typeof(SqlDateTime),rdr.GetProviderSpecificFieldType(3),"#4 The 
column at index 3 must have FieldType as SqlString");
+                               }
+                               cmd.CommandText = "SELECT * FROM 
numeric_family";
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (12, rdr.FieldCount, 
"#5");
+                                       
Assert.AreEqual(typeof(SqlBoolean),rdr.GetProviderSpecificFieldType(1),"#6 The 
column at index 0 must have FieldType as SqlString");
+                                       
Assert.AreEqual(typeof(SqlByte),rdr.GetProviderSpecificFieldType(2),"#7 The 
column at index 1 must have FieldType as SqlString");
+                                       
Assert.AreEqual(typeof(SqlDecimal),rdr.GetProviderSpecificFieldType(6),"#8 The 
column at index 3 must have FieldType as SqlString");
+                                       
Assert.AreEqual(typeof(SqlMoney),rdr.GetProviderSpecificFieldType(8),"#9 The 
column at index 3 must have FieldType as SqlString");
+                                       
Assert.AreEqual(typeof(SqlSingle),rdr.GetProviderSpecificFieldType(10),"#10 The 
column at index 3 must have FieldType as SqlString");
+                                       
Assert.AreEqual(typeof(SqlDouble),rdr.GetProviderSpecificFieldType(11),"#11 The 
column at index 3 must have FieldType as SqlString");
+                               }
+                       }
+               }
+
+               //FIXME : Add more test cases
+               [Test]
+               public void GetProviderSpecificValueTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (6, rdr.FieldCount, 
"#1");
+                                       
Assert.AreEqual((SqlInt32)1,rdr.GetProviderSpecificValue(0),"#2 The column at 
index 0 must have FieldType as SqlString");
+                                       
Assert.AreEqual((SqlString)"suresh",rdr.GetProviderSpecificValue(1),"#3 The 
column at index 1 must have FieldType as SqlString");
+                                       
Assert.AreEqual((SqlDateTime)DateTime.Parse("8/22/1978"),rdr.GetProviderSpecificValue(3),"#4
 The column at index 3 must have FieldType as SqlString");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetProviderSpecificValueLowerBoundaryTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (6, rdr.FieldCount, 
"#1");
+                                       try {
+                                               
Assert.AreEqual((SqlInt32)1,rdr.GetProviderSpecificValue(-1),"#2 The column at 
index 0 must have FieldType as SqlString");
+                                       } catch (IndexOutOfRangeException) {
+                                               
Assert.AreEqual((SqlInt32)1,rdr.GetProviderSpecificValue(0),"#2 The column at 
index 0 must have FieldType as SqlString");
+                                               
Assert.AreEqual((SqlString)"suresh",rdr.GetProviderSpecificValue(1),"#3 The 
column at index 1 must have FieldType as SqlString");
+                                               
Assert.AreEqual((SqlDateTime)DateTime.Parse("8/22/1978"),rdr.GetProviderSpecificValue(3),"#4
 The column at index 3 must have FieldType as SqlString");
+                                               return;
+                                       }
+                                       Assert.Fail ("Expected exception 
IndexOutOfRangeException was not thrown");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetProviderSpecificValueUpperBoundaryTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (6, rdr.FieldCount, 
"#1");
+                                       try {
+                                               
Assert.AreEqual((SqlInt32)1,rdr.GetProviderSpecificValue(rdr.FieldCount),"#2 
The column at index 0 must have FieldType as SqlString");
+                                       } catch (IndexOutOfRangeException) {
+                                               
Assert.AreEqual((SqlInt32)1,rdr.GetProviderSpecificValue(0),"#2 The column at 
index 0 must have FieldType as SqlString");
+                                               
Assert.AreEqual((SqlString)"suresh",rdr.GetProviderSpecificValue(1),"#3 The 
column at index 1 must have FieldType as SqlString");
+                                               
Assert.AreEqual((SqlDateTime)DateTime.Parse("8/22/1978"),rdr.GetProviderSpecificValue(3),"#4
 The column at index 3 must have FieldType as SqlString");
+                                               return;
+                                       }
+                                       Assert.Fail ("Expected exception 
IndexOutOfRangeException was not thrown");
+                               }
+                       }
+               }
+
+               //FIXME : Add more test cases
+               [Test]
+               public void GetProviderSpecificValuesTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               Object [] psValues = new Object[6];
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       rdr.GetProviderSpecificValues 
(psValues);
+                                       Assert.AreEqual ((SqlInt32)1, 
psValues[0], "#");
+                                       Assert.AreEqual ((SqlString)"suresh", 
psValues[1], "#");
+                                       Assert.AreEqual 
((SqlDateTime)DateTime.Parse("8/22/1978"), psValues[3], "#");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetProviderSpecificValuesSmallArrayTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               Object [] psValues = new Object[2];
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       rdr.GetProviderSpecificValues 
(psValues);
+                                       Assert.AreEqual ((SqlInt32)1, 
psValues[0], "#");
+                                       Assert.AreEqual ((SqlString)"suresh", 
psValues[1], "#");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetProviderSpecificValuesLargeArrayTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               Object [] psValues = new Object[10];
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       rdr.GetProviderSpecificValues 
(psValues);
+                                       Assert.AreEqual ((SqlInt32)1, 
psValues[0], "#");
+                                       Assert.AreEqual ((SqlString)"suresh", 
psValues[1], "#");
+                                       Assert.AreEqual 
((SqlDateTime)DateTime.Parse("8/22/1978"), psValues[3], "#");
+                                       Assert.AreEqual (null, psValues[6], 
"#");
+                                       Assert.AreEqual (null, psValues[9], 
"#");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetProviderSpecificValuesNullTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               Object [] psValues = new Object[2];
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       try {
+                                               rdr.GetProviderSpecificValues 
(null);
+                                       } catch (NullReferenceException) {
+                                               Assert.AreEqual (null, 
psValues[0], "#");
+                                               Assert.AreEqual (null, 
psValues[1], "#");
+                                               return;
+                                       }
+                                       Assert.Fail ("Expected exception 
NullReferenceException was not thrown");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetSqlBytesTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection 
(connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM binary_family";
+                               using (SqlDataReader rdr = cmd.ExecuteReader 
()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (7, rdr.FieldCount, 
"#1");
+                                       
+                                       SqlBytes sb = rdr.GetSqlBytes (1);
+                                       long byteCount = sb.Length;
+                                       Assert.AreEqual (1, byteCount, "#");
+                                       Assert.AreEqual (53, sb[0], "#");
+
+                                       sb = rdr.GetSqlBytes (2);
+                                       Assert.AreEqual (typeof(SqlBinary), 
rdr.GetSqlValue(2).GetType(), "#");
+                                       byteCount = sb.Length;
+                                       Assert.AreEqual (30, byteCount, "#");
+                                       Assert.AreEqual (48, sb[0], "#");
+                                       Assert.AreEqual (49, sb[1], "#");
+                                       Assert.AreEqual (50, sb[2], "#");
+                                       Assert.AreEqual (53, sb[15], "#");
+                                       Assert.AreEqual (57, sb[29], "#");      
                                
+                               }
+                       }
+                       
+               }
+
+#endif // NET_2_0
+
        }
 }

Modified: 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterTest.cs
===================================================================
--- 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterTest.cs
    2007-05-04 04:07:41 UTC (rev 76655)
+++ 
trunk/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterTest.cs
    2007-05-04 04:08:23 UTC (rev 76656)
@@ -3,6 +3,7 @@
 //                          SqlParameter class
 // Author:
 //      Senganal T ([EMAIL PROTECTED])
+//      Amit Biswas ([EMAIL PROTECTED])
 //
 // Copyright (c) 2004 Novell Inc., and the individuals listed
 // on the ChangeLog entries.
@@ -61,8 +62,8 @@
                public void ParameterType ()
                {
                        // If Type is not set, then type is inferred from the 
value
-                       // assigned. The Type should inferred everytime Value 
is assigned
-                       // If value is null/DBNull, then the current Type 
should retained.
+                       // assigned. The Type should be inferred everytime 
Value is assigned
+                       // If value is null or DBNull, then the current Type 
should be reset to NVarChar.
                        SqlParameter param = new SqlParameter ();
                        Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, 
"#1");
                        param.Value = DBNull.Value;
@@ -70,27 +71,232 @@
                        param.Value = 1;
                        Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#3");
                        param.Value = DBNull.Value;
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#4");
+                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, 
"#4");
                        param.Value = null;
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#4");
+                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, 
"#5");
 
                        //If Type is set, then the Type should not inferred 
from the value 
                        //assigned.
                        SqlParameter param1 = new SqlParameter ();
                        param1.DbType = DbType.String; 
-                       Assert.AreEqual (SqlDbType.NVarChar, param1.SqlDbType, 
"#5");
+                       Assert.AreEqual (SqlDbType.NVarChar, param1.SqlDbType, 
"#6");
                        param1.Value = 1;
-                       Assert.AreEqual (SqlDbType.NVarChar, param1.SqlDbType, 
"#6");
+                       Assert.AreEqual (SqlDbType.NVarChar, param1.SqlDbType, 
"#7");
 
                        SqlParameter param2 = new SqlParameter ();
                        param2.SqlDbType = SqlDbType.NVarChar;
-                       Assert.AreEqual (SqlDbType.NVarChar, param2.SqlDbType, 
"#7");
+                       Assert.AreEqual (SqlDbType.NVarChar, param2.SqlDbType, 
"#8");
                        param2.Value = 1;
-                       Assert.AreEqual (SqlDbType.NVarChar, param2.SqlDbType, 
"#8");
+                       Assert.AreEqual (SqlDbType.NVarChar, param2.SqlDbType, 
"#9");
                }
 
+               [Test]
+               public void SqlDbTypeTest ()
+               {
+                       SqlParameter p1 = new SqlParameter ();
+                       Assert.AreEqual (null, p1.Value, "#1 Value of the 
parameter must be null by default");
+                       Assert.AreEqual (SqlDbType.NVarChar, p1.SqlDbType, "#2 
parameters without any value or null value must have SqlDbtype as NVarChar");
+                       Assert.AreEqual (DbType.String, p1.DbType, "#3 
parameters without any value must have DbType as NVarChar");
+                       
+                       SqlParameter p2 = new SqlParameter ("#4 p2Name", 
(Object)null);
+                       Assert.AreEqual (null, p2.Value, "#5 Value of the 
parameter must be null by default");
+                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#6 
parameters without any value or null value must have SqlDbtype as NVarChar");
+                       Assert.AreEqual (DbType.String, p2.DbType, 
"#7parameters without any value or null value must have DbType as String");
+                       
+                       p2.Value = Convert.ToInt32(42);
+                       Assert.AreEqual (42, p2.Value, "#8 Value of the 
parameter must be 42");
+                       Assert.AreEqual (SqlDbType.Int, p2.SqlDbType, "#9 
parameter must have SqlDbtype as Int");
+                       Assert.AreEqual (DbType.Int32, p2.DbType, "#10 
parameter must have Dbtype as Int32");
+
+                       p2.Value = DBNull.Value;
+                       Assert.AreEqual (DBNull.Value, p2.Value, "#11 Value of 
the parameter must be DBNull.Value");
+                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#12 
parameters without any value or null value must have SqlDbtype as NVarChar");
+                       Assert.AreEqual (DbType.String, p2.DbType, "#13 
parameters without any value or null value must have DbType as String");
+
+               }
+
 #if NET_2_0
                [Test]
+               public void ResetSqlDbTypeTest ()
+               {
+                       //Parameter with an assigned value but no SqlDbType 
specified
+                       SqlParameter p1 = new SqlParameter ("foo", 42);
+                       Assert.AreEqual (42, p1.Value, "#1");
+                       Assert.AreEqual (DbType.Int32, p1.DbType, "#2");
+                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#3");
+
+                       p1.ResetSqlDbType ();
+                       Assert.AreEqual (DbType.Int32, p1.DbType, "#4 The 
parameter with value 42 must have DbType as Int32");
+                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#5 The 
parameter with value 42 must have SqlDbType as Int");
+
+                       p1.SqlDbType = SqlDbType.DateTime; //assigning a 
SqlDbType
+                       Assert.AreEqual (DbType.DateTime, p1.DbType, "#6");
+                       Assert.AreEqual (SqlDbType.DateTime, p1.SqlDbType, 
"#7");
+                       p1.ResetSqlDbType (); //Resetting SqlDbType
+                       Assert.AreEqual (DbType.Int32, p1.DbType, "#8 Resetting 
SqlDbType must infer the type from the value");
+                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#9 
Resetting SqlDbType must infer the type from the value");
+
+                       //Parameter with an assigned SqlDbType but no specified 
value
+                       SqlParameter p2 = new SqlParameter ("foo", 
SqlDbType.Int);
+                       Assert.AreEqual (null, p2.Value, "#10");
+                       Assert.AreEqual (DbType.Int32, p2.DbType, "#11");
+                       Assert.AreEqual (SqlDbType.Int, p2.SqlDbType, "#12");
+
+                       //Although a SqlDbType is specified, calling 
ResetSqlDbType resets 
+                       //the SqlDbType and DbType properties to default values
+                       p2.ResetSqlDbType ();
+                       Assert.AreEqual (DbType.String, p2.DbType, "#13 
Resetting SqlDbType must infer the type from the value");
+                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#14 
Resetting SqlDbType must infer the type from the value");
+
+                       p2.SqlDbType = SqlDbType.DateTime; //assigning a 
SqlDbType
+                       Assert.AreEqual (DbType.DateTime, p2.DbType, "#15");
+                       Assert.AreEqual (SqlDbType.DateTime, p2.SqlDbType, 
"#16");
+                       p2.ResetSqlDbType (); //Resetting SqlDbType
+                       Assert.AreEqual (DbType.String, p2.DbType, "#17 
Resetting SqlDbType must infer the type from the value");
+                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#18 
Resetting SqlDbType must infer the type from the value");
+               }
+
+               [Test]
+               public void ResetDbTypeTest ()
+               {
+                       //Parameter with an assigned value but no DbType 
specified
+                       SqlParameter p1 = new SqlParameter ("foo", 42);
+                       Assert.AreEqual (42, p1.Value, "#1");
+                       Assert.AreEqual (DbType.Int32, p1.DbType, "#2");
+                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#3");
+
+                       p1.ResetDbType ();
+                       Assert.AreEqual (DbType.Int32, p1.DbType, "#4 The 
parameter with value 42 must have DbType as Int32");
+                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#5 The 
parameter with value 42 must have SqlDbType as Int32");
+
+                       p1.DbType = DbType.DateTime; //assigning a DbType
+                       Assert.AreEqual (DbType.DateTime, p1.DbType, "#6");
+                       Assert.AreEqual (SqlDbType.DateTime, p1.SqlDbType, 
"#7");
+                       p1.ResetDbType (); //Resetting DbType
+                       Assert.AreEqual (DbType.Int32, p1.DbType, "#8 Resetting 
DbType must infer the type from the value");
+                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#9 
Resetting DbType must infer the type from the value");
+
+                       //Parameter with an assigned SqlDbType but no specified 
value
+                       SqlParameter p2 = new SqlParameter ("foo", 
SqlDbType.Int);
+                       Assert.AreEqual (null, p2.Value, "#10");
+                       Assert.AreEqual (DbType.Int32, p2.DbType, "#11");
+                       Assert.AreEqual (SqlDbType.Int, p2.SqlDbType, "#12");
+
+                       //Although a SqlDbType is specified, calling 
ResetDbType resets 
+                       //the SqlDbType and DbType properties to default values
+                       p2.ResetDbType (); 
+                       Assert.AreEqual (DbType.String, p2.DbType, "#13 
Resetting DbType must infer the type from the value");
+                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#14 
Resetting DbType must infer the type from the value");
+
+                       p2.DbType = DbType.DateTime; //assigning a SqlDbType
+                       Assert.AreEqual (DbType.DateTime, p2.DbType, "#15");
+                       Assert.AreEqual (SqlDbType.DateTime, p2.SqlDbType, 
"#16");
+                       p2.ResetDbType (); //Resetting DbType
+                       Assert.AreEqual (DbType.String, p2.DbType, "#17 
Resetting DbType must infer the type from the value");
+                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#18 
Resetting DbType must infer the type from the value");
+               }
+
+               [Test]
+               public void XmlSchemaTest ()
+               {
+                       SqlParameter p1 = new SqlParameter ();
+                       
+                       //Testing default values
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionDatabase,
+                                        "#1 Default value for 
XmlSchemaCollectionDatabase is an empty string");
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionName,
+                                        "#2 Default value for 
XmlSchemaCollectionName is an empty string");
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionOwningSchema,
+                                        "#3 Default value for 
XmlSchemaCollectionOwningSchema is an empty string");
+
+                       //Changing one property should not affect the remaining 
two properties
+                       p1.XmlSchemaCollectionDatabase = "database";
+                       Assert.AreEqual ("database", 
p1.XmlSchemaCollectionDatabase,
+                                        "#4 Default value for 
XmlSchemaCollectionDatabase is an empty string");
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionName,
+                                        "#5 Default value for 
XmlSchemaCollectionName is an empty string");
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionOwningSchema,
+                                        "#6 Default value for 
XmlSchemaCollectionOwningSchema is an empty string");
+
+                       p1.XmlSchemaCollectionName = "name";
+                       Assert.AreEqual ("database", 
p1.XmlSchemaCollectionDatabase,
+                                        "#7 Default value for 
XmlSchemaCollectionDatabase is an empty string");
+                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName,
+                                        "#8 Default value for 
XmlSchemaCollectionName is an empty string");
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionOwningSchema,
+                                        "#9 Default value for 
XmlSchemaCollectionOwningSchema is an empty string");
+
+                       p1.XmlSchemaCollectionOwningSchema = "schema";
+                       Assert.AreEqual ("database", 
p1.XmlSchemaCollectionDatabase,
+                                        "#10 Default value for 
XmlSchemaCollectionDatabase is an empty string");
+                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName,
+                                        "#11 Default value for 
XmlSchemaCollectionName is an empty string");
+                       Assert.AreEqual ("schema", 
p1.XmlSchemaCollectionOwningSchema,
+                                        "#12 Default value for 
XmlSchemaCollectionOwningSchema is an empty string");
+
+                       //assigning null value stores default empty string
+                       p1.XmlSchemaCollectionDatabase = null;
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionDatabase,
+                                        "#13 Default value for 
XmlSchemaCollectionDatabase is an empty string");
+                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName,
+                                        "#14 Default value for 
XmlSchemaCollectionName is an empty string");
+                       Assert.AreEqual ("schema", 
p1.XmlSchemaCollectionOwningSchema,
+                                        "#15 Default value for 
XmlSchemaCollectionOwningSchema is an empty string");
+
+                       p1.XmlSchemaCollectionName = "";
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionDatabase,
+                                        "#16 Default value for 
XmlSchemaCollectionDatabase is an empty string");
+                       Assert.AreEqual ("", p1.XmlSchemaCollectionName,
+                                        "#17 Default value for 
XmlSchemaCollectionName is an empty string");
+                       Assert.AreEqual ("schema", 
p1.XmlSchemaCollectionOwningSchema,
+                                        "#18 Default value for 
XmlSchemaCollectionOwningSchema is an empty string");
+
+                       //values are not trimmed
+                       p1.XmlSchemaCollectionOwningSchema = "  a  ";
+                       Assert.AreEqual (String.Empty, 
p1.XmlSchemaCollectionDatabase,
+                                        "#19 Default value for 
XmlSchemaCollectionDatabase is an empty string");
+                       Assert.AreEqual ("", p1.XmlSchemaCollectionName,
+                                        "#20 Default value for 
XmlSchemaCollectionName is an empty string");
+                       Assert.AreEqual ("  a  ", 
p1.XmlSchemaCollectionOwningSchema,
+                                        "#21 Default value for 
XmlSchemaCollectionOwningSchema is an empty string");
+               }
+
+               [Test]
+               public void SourceColumnNullMappingTest ()
+               {
+                       SqlParameter p1 = new SqlParameter ();
+                       Assert.AreEqual (false, p1.SourceColumnNullMapping, "#1 
SourceColumnNullMapping should be false by default");
+                       p1.SourceColumnNullMapping = true;
+                       Assert.AreEqual (true, p1.SourceColumnNullMapping, "#2 
SourceColumnNullMapping should be false by default");
+               }
+
+               [Test]
+               public void ctor7Test ()
+               {
+                       SqlParameter p1 = new SqlParameter ("p1Name", 
SqlDbType.VarChar, 20,
+                                                           
ParameterDirection.InputOutput, 0, 0,
+                                                           "srcCol", 
DataRowVersion.Original, false,
+                                                           "foo", "database", 
"schema", "name");
+                       Assert.AreEqual (DbType.AnsiString, p1.DbType, "#");
+                       Assert.AreEqual (ParameterDirection.InputOutput, 
p1.Direction, "#");
+                       Assert.AreEqual (false, p1.IsNullable, "#");
+                       //Assert.AreEqual (999, p1.LocaleId, "#");
+                       Assert.AreEqual ("p1Name", p1.ParameterName, "#");
+                       Assert.AreEqual (0, p1.Precision, "#");
+                       Assert.AreEqual (0, p1.Scale, "#");
+                       Assert.AreEqual (20, p1.Size, "#");
+                       Assert.AreEqual ("srcCol", p1.SourceColumn, "#");
+                       Assert.AreEqual (false, p1.SourceColumnNullMapping, 
"#");
+                       Assert.AreEqual (DataRowVersion.Original, 
p1.SourceVersion, "#");
+                       Assert.AreEqual (SqlDbType.VarChar, p1.SqlDbType, "#");
+                       //Assert.AreEqual (3210, p1.SqlValue, "#");
+                       Assert.AreEqual ("foo", p1.Value, "#");
+                       Assert.AreEqual ("database", 
p1.XmlSchemaCollectionDatabase, "#");
+                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName, 
"#");
+                       Assert.AreEqual ("schema", 
p1.XmlSchemaCollectionOwningSchema, "#");
+               }
+
+               [Test]
                public void CompareInfoTest ()
                {
                        SqlParameter parameter = new SqlParameter ();

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

Reply via email to