|
|
@@ -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");
|