Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGert Driesen <drieseng@users.sourceforge.net>2008-12-31 18:35:07 +0300
committerGert Driesen <drieseng@users.sourceforge.net>2008-12-31 18:35:07 +0300
commit25c01a2252aaacc8cef9b6de4849c286a02f477d (patch)
treec6c8dae1fbf2180b82ec0627e80deaeb9f1b111d /mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcDataReaderTest.cs
parent30bf4c6e4bcc824ef2cbea4b4a6e5a521363f03c (diff)
parent39a234d167b867cb01f0397b6244775bf291ab8d (diff)
* app-default.config: Renamed to app-net_1_1.config, and added
providerTests section. * app-net_2.0.config: Added providerTests section and removed mono.data section. * Makefile: Added support for CONNECTION variable and corresponding PROVIDER_TESTS_CONNECTION environment variable. Always rebuild test assembly since we have no dependency check for sources in place. Only add reference to Mono.Data on 1.1 profile. Added reference to System.Configuration on 2.0 profile. * sqlserver.config: Merged into app-*.config. * odbc.config: Merged into app-*.config. * System.Data.Connected.Tests.dll.sources: Added ConnectionConfig.cs, EngineConfig.cs, EngineType.cs, ProviderTestsConfigurationHandler.cs and DbDataReaderTest.cs. Removed OdbcConnectionStringBuilderTest.cs. * ConnectionConfig.cs: Holds information on a specific connection and corresponding engine to test. * EngineConfig.cs: Holds information on the capabilities and behavior of an RDBMS engine. * EngineType.cs: Defines different database engines supported by the provider tests. * ConnectionManager.cs: Use DbProviderFactory and DbConnection on 2.0 profile. Added support for new Connection/Engine configuration. * ProviderTestsConfigurationHandler.cs: IConfigurationSectionHandler for the ProviderTests section. * DataReaderTest.cs: Added tests that were previously part of SqlClient tests but apply to all families. Improved existing tests. * DbDataReaderTest.cs: Added GetProviderSpecificValues error check tests. * IDbCommandTest.cs: Added ExecuteNonQuery tests for empty CommandText. Added test for bug #462947. * OdbcCommandBuilderTest.cs: Improved GetDeleteCommand, GetInsertCommand and GetUpdateCommand tests. Added QuotePrefix, QuoteSuffix and QuoteIdentifier tests. * OdbcCommandTest.cs: Improved existing tests. Added ExecuteNonQuery and Dispose tests. * OdbcConnectionStringBuilderTest.cs: Moved to System.Data test suite. * OdbcDataAdapterTest.cs: Removed extra whitespace. * OdbcDataReaderTest.cs: Added GetBytes and GetSchemaTable tests. * OdbcParameterCollectionTest.cs: Improve existing tests. * OdbcParameterTest.cs: Added tests for several data types. * SqlCommandBuilderTest.cs: Improve Get*Command tests. * SqlCommandTest.cs: Added test for bug #341743. Added test for connection state after executing invalid SQL. Improved stored procedure test to check behavior with and without leading '@' for parameter names. Minor formatting changes. * SqlConnectionTest.cs: Split up connection string errors test. * SqlDataReaderTest.cs: Improved GetInt64Test. Improved and added GetBytes tests. Added GetSqlValues and HasRows tests. Added GetSchemaTable test. Improved GetProviderSpecificFieldType tests. * SqlParameterTest.cs: Improved ParameterType test. Added type inferrence tests. * SqlTransactionTest.cs: Allow not working tests to run on MS. * MySQL_5.sql: Added numeric and decimal colums with different precision and scale. Added more rows to binary_family. Added nchar and nvarchar columns to string_family, and added extra data. Added time and date columns to datetime_family. * sqlserver.sql: Added numeric and decimal colums with different precision and scale. Added timestamp column and more rows to binary_family. Added nchar and nvarchar columns to string_family, and added extra data. Added sp_326182 stored procedure. * sybase.sql: Added more rows to binary_family. svn path=/trunk/mcs/; revision=122297
Diffstat (limited to 'mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcDataReaderTest.cs')
-rw-r--r--mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcDataReaderTest.cs1292
1 files changed, 999 insertions, 293 deletions
diff --git a/mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcDataReaderTest.cs b/mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcDataReaderTest.cs
index a3d0672b737..d371d638f4a 100644
--- a/mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcDataReaderTest.cs
+++ b/mcs/class/System.Data/Test/ProviderTests/System.Data.Odbc/OdbcDataReaderTest.cs
@@ -29,10 +29,12 @@
//
using System;
-using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.Odbc;
+using System.Globalization;
+using System.Text;
+
using Mono.Data;
using NUnit.Framework;
@@ -43,130 +45,966 @@ namespace MonoTests.System.Data
[Category ("odbc")]
public class OdbcDataReaderTest
{
+ static byte [] long_bytes = new byte [] {
+ 0x00, 0x66, 0x06, 0x66, 0x97, 0x00, 0x66, 0x06, 0x66,
+ 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06,
+ 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66,
+ 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06,
+ 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97,
+ 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66,
+ 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06,
+ 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66,
+ 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06,
+ 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97,
+ 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66,
+ 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06,
+ 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66,
+ 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06,
+ 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97,
+ 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66,
+ 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06,
+ 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66,
+ 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06,
+ 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97,
+ 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66,
+ 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06,
+ 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66,
+ 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06,
+ 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97,
+ 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66,
+ 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06,
+ 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06, 0x66,
+ 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97, 0x06,
+ 0x66, 0x06, 0x66, 0x97, 0x06, 0x66, 0x06, 0x66, 0x97,
+ 0x06, 0x66, 0x06, 0x66, 0x98};
+
+ OdbcConnection conn;
+ OdbcCommand cmd;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
+ ConnectionManager.Singleton.OpenConnection ();
+ cmd = conn.CreateCommand ();
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (cmd != null)
+ cmd.Dispose ();
+ ConnectionManager.Singleton.CloseConnection ();
+ }
+
+ [Test]
+ public void GetBytes ()
+ {
+ cmd.CommandText = "SELECT type_blob FROM binary_family where id = 1";
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SingleResult | CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read (), "#C1");
+
+ long totalsize = reader.GetBytes (0, 0, null, 0, 0);
+
+ byte [] val = new byte [totalsize];
+ long ret = reader.GetBytes (0, 0L, val, 0, (int) (totalsize * 2));
+ Assert.AreEqual (totalsize, ret, "#C2");
+ Assert.AreEqual (new byte [] { 0x32, 0x56, 0x00, 0x44, 0x22 }, val, "#C3");
+ }
+
+ cmd.CommandText = "SELECT type_blob FROM binary_family where id = 2";
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SingleResult | CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read (), "#G1");
+
+ long totalsize = reader.GetBytes (0, 0, null, 0, 0);
+
+ byte [] val = new byte [totalsize];
+ int offset = 0;
+ long ret = 0;
+ long count = 0;
+ do {
+ ret = reader.GetBytes (0, offset, val, offset, 50);
+ offset += (int) ret;
+ count += ret;
+ } while (count < totalsize);
+
+ Assert.AreEqual (long_bytes.Length, count, "#G2");
+ Assert.AreEqual (long_bytes, val, "#G3");
+ }
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SingleResult)) {
+ Assert.IsTrue (reader.Read (), "#H1");
+
+ long totalsize = reader.GetBytes (0, 0, null, 0, 0);
+
+ byte [] val = new byte [totalsize];
+ int offset = 0;
+ long ret = 0;
+ long count = 0;
+ do {
+ ret = reader.GetBytes (0, offset, val, offset, 50);
+ offset += (int) ret;
+ count += ret;
+ } while (count < totalsize);
+
+ Assert.AreEqual (long_bytes.Length, count, "#H2");
+ Assert.AreEqual (long_bytes, val, "#H3");
+ }
+ }
+
+ [Test]
+ public void GetBytes_Buffer_TooSmall ()
+ {
+ cmd.CommandText = "SELECT type_blob FROM binary_family where id = 2";
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SingleResult | CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read ());
+
+ long totalsize = reader.GetBytes (0, 0, null, 0, 0);
+ byte [] val = new byte [totalsize - 1];
+
+ long ret = reader.GetBytes (0, 0, val, 0, (int) totalsize);
+ Assert.AreEqual (274, ret, "#A1");
+ for (int i = 0; i < ret; i++)
+ Assert.AreEqual (long_bytes [i], val [i], "#A2:" + i);
+ for (long i = ret; i < val.Length; i++)
+ Assert.AreEqual (0x00, val [i], "#A3:" + i);
+ }
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SingleResult | CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read ());
+
+ long totalsize = reader.GetBytes (0, 0, null, 0, 0);
+ byte [] val = new byte [totalsize];
+ int buffer_offset = 1;
+
+#if NET_2_0
+ long ret = reader.GetBytes (0, 0, val, buffer_offset, (int) totalsize);
+ Assert.AreEqual (274, ret, "#B1");
+ Assert.AreEqual (0x00, val [0], "#B2");
+ for (int i = 0; i < ret; i++)
+ Assert.AreEqual (long_bytes [i], val [i + buffer_offset], "#B2:" + i);
+ for (long i = (ret + buffer_offset); i < val.Length; i++)
+ Assert.AreEqual (0x00, val [i], "#B3:" + i);
+#else
+ try {
+ reader.GetBytes (0, 0, val, buffer_offset, (int) totalsize);
+ Assert.Fail ("#B1");
+ } catch (ArgumentOutOfRangeException ex) {
+ // Requested range extends past the end
+ // of the array
+ Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNull (ex.ParamName, "#B5");
+ }
+#endif
+ }
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SingleResult | CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read ());
+
+ long totalsize = reader.GetBytes (0, 0, null, 0, 0);
+ byte [] val = new byte [totalsize];
+
+ long ret = reader.GetBytes (0, 0, val, 0, (int) (totalsize + 1));
+ Assert.AreEqual (totalsize, ret, "#C1");
+ }
+
+ ConnectionManager.Singleton.CloseConnection ();
+ }
+
+ [Test]
+ public void GetBytes_BufferIndex_Negative ()
+ {
+ cmd.CommandText = "SELECT type_blob FROM binary_family where id = 1";
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read (), "#1");
+
+ try {
+ reader.GetBytes (0, 0, null, -1, 0);
+ Assert.Fail ("#2");
+#if NET_2_0
+ } catch (ArgumentOutOfRangeException ex) {
+ Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#3");
+ Assert.IsNull (ex.InnerException, "#4");
+ Assert.IsNotNull (ex.Message, "#5");
+ Assert.AreEqual ("bufferIndex", ex.ParamName, "#6");
+ }
+#else
+ } catch (ArgumentException ex) {
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#3");
+ Assert.IsNull (ex.InnerException, "#4");
+ Assert.AreEqual ("bufferIndex", ex.Message, "#5");
+ Assert.IsNull (ex.ParamName, "#6");
+ }
+#endif
+ }
+ }
+
+ [Test]
+#if ONLY_1_1
+ [Ignore ("dataIndex is ignored")]
+#endif
+ public void GetBytes_DataIndex_Negative ()
+ {
+ IDbCommand cmd = conn.CreateCommand ();
+ cmd.CommandText = "SELECT type_blob FROM binary_family where id = 1";
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read (), "#A1");
+
+#if NET_2_0
+ try {
+ reader.GetBytes (0, -1L, null, 0, 0);
+ Assert.Fail ("#A2");
+ } catch (ArgumentOutOfRangeException ex) {
+ Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#A3");
+ Assert.IsNull (ex.InnerException, "#A4");
+ Assert.IsNotNull (ex.Message, "#A5");
+ Assert.AreEqual ("dataIndex", ex.ParamName, "#A6");
+ }
+#else
+ long totalsize = reader.GetBytes (0, -1L, null, 0, 0);
+ Assert.AreEqual (5, totalsize, "#A2");
+
+ byte [] val = new byte [totalsize];
+ try {
+ reader.GetBytes (0, -1L, val, 0, 3);
+ Assert.Fail ("#A3");
+ } catch (InvalidOperationException ex) {
+ // Invalid GetBytes attempt at dataIndex '-1'.
+ // With CommandBehavior.SequentialAccess, you
+ // may only read from dataIndex '0' or greater
+ Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A4");
+ Assert.IsNull (ex.InnerException, "#A5");
+ Assert.IsNotNull (ex.Message, "#A6");
+ Assert.IsTrue (ex.Message.IndexOf ("CommandBehavior.SequentialAccess") != -1, "#A7:" + ex.Message);
+ Assert.IsTrue (ex.Message.IndexOf ("'" + (-1L).ToString (CultureInfo.InvariantCulture) + "'") != -1, "#A8:" + ex.Message);
+ Assert.IsTrue (ex.Message.IndexOf ("'" + 0L.ToString (CultureInfo.InvariantCulture) + "'") != -1, "#A9:" + ex.Message);
+ }
+#endif
+ }
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SingleResult)) {
+ Assert.IsTrue (reader.Read (), "#B1");
+
+#if NET_2_0
+ try {
+ reader.GetBytes (0, -1L, null, 0, 0);
+ Assert.Fail ("#B2");
+ } catch (ArgumentOutOfRangeException ex) {
+ Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#B3");
+ Assert.IsNull (ex.InnerException, "#B4");
+ Assert.IsNotNull (ex.Message, "#B5");
+ Assert.AreEqual ("dataIndex", ex.ParamName, "#B6");
+ }
+#else
+ long totalsize = reader.GetBytes (0, -1L, null, 0, 0);
+ Assert.AreEqual (5, totalsize, "#B2");
+
+ byte [] val = new byte [totalsize];
+ try {
+ reader.GetBytes (0, -1L, val, 0, 3);
+ Assert.Fail ("#B3");
+ } catch (ArgumentOutOfRangeException) {
+ }
+#endif
+ }
+ }
+
+ [Test]
+ public void GetBytes_Length_Negative ()
+ {
+ cmd.CommandText = "SELECT type_blob FROM binary_family where id = 1";
+
+ using (IDataReader reader = cmd.ExecuteReader (CommandBehavior.SequentialAccess)) {
+ Assert.IsTrue (reader.Read (), "#1");
+
+ try {
+ reader.GetBytes (0, 0, null, 0, -1);
+ Assert.Fail ("#2");
+#if NET_2_0
+ } catch (ArgumentOutOfRangeException ex) {
+ Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#3");
+ Assert.IsNull (ex.InnerException, "#4");
+ Assert.IsNotNull (ex.Message, "#5");
+ Assert.AreEqual ("length", ex.ParamName, "#6");
+ }
+#else
+ } catch (ArgumentException ex) {
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#3");
+ Assert.IsNull (ex.InnerException, "#4");
+ Assert.AreEqual ("length", ex.Message, "#5");
+ Assert.IsNull (ex.ParamName, "#6");
+ }
+#endif
+ }
+ }
+
+ [Test]
+ public void GetSchemaTable ()
+ {
+ IDataReader reader = null;
+ DataTable schema;
+ DataRow pkRow;
+
+ try {
+ cmd.CommandText = "select id, fname, id + 20 as plustwenty from employee";
+ reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#A:");
+ Assert.AreEqual (3, schema.Rows.Count, "#A:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#A:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#A:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#A:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#A:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#A:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#A:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#A:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#A:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#A:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#A:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#A:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#A:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#A:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#A:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#A:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#A:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#A:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#A:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#A:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#A:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#A:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#A:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#A:IsUnique_IsNull");
+ Assert.AreEqual (true, pkRow ["IsUnique"], "#A:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#A:IsKey_IsNull");
+ Assert.AreEqual (true, pkRow ["IsKey"], "#A:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#A:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#A:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#A:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#A:BaseSchemaName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#A:BaseCatalogName_IsNull");
+ Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#A:BaseCatalogName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#A:BaseTableName_IsNull");
+ Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#A:BaseTableName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#A:BaseColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#A:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#B:");
+ Assert.AreEqual (3, schema.Rows.Count, "#B:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#B:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#B:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#B:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#B:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#B:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#B:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#B:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#B:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#B:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#B:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#B:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#B:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#B:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#B:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#B:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#B:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#B:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#B:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#B:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#B:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#B:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#B:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#B:IsUnique_IsNull");
+ Assert.AreEqual (false, pkRow ["IsUnique"], "#B:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#B:IsKey_IsNull");
+ Assert.AreEqual (false, pkRow ["IsKey"], "#B:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#B:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#B:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#B:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#B:BaseSchemaName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#B:BaseCatalogName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#B:BaseCatalogName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#B:BaseTableName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#B:BaseTableName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#B:BaseColumnName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#B:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader (CommandBehavior.KeyInfo);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#C:");
+ Assert.AreEqual (3, schema.Rows.Count, "#C:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#C:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#C:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#C:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#C:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#C:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#C:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#C:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#C:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#C:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#C:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#C:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#C:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#C:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#C:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#C:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#C:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#C:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#C:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#C:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#C:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#C:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#C:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#C:IsUnique_IsNull");
+ Assert.AreEqual (true, pkRow ["IsUnique"], "#C:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#C:IsKey_IsNull");
+ Assert.AreEqual (true, pkRow ["IsKey"], "#C:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#C:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#C:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#C:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#C:BaseSchemaName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#C:BaseCatalogName_IsNull");
+ Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#C:BaseCatalogName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#C:BaseTableName_IsNull");
+ Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#C:BaseTableName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#C:BaseColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#C:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader ();
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#D:");
+ Assert.AreEqual (3, schema.Rows.Count, "#D:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#D:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#D:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#D:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#D:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#D:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#D:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#D:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#D:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#D:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#D:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#D:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#D:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#D:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#D:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#D:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#D:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#D:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#D:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#D:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#D:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#D:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#D:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#D:IsUnique_IsNull");
+ Assert.AreEqual (false, pkRow ["IsUnique"], "#D:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#D:IsKey_IsNull");
+ Assert.AreEqual (false, pkRow ["IsKey"], "#D:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#D:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#D:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#D:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#D:BaseSchemaName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#D:BaseCatalogName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#D:BaseCatalogName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#D:BaseTableName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#D:BaseTableName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#D:BaseColumnName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#D:BaseColumnName_Value");
+
+ cmd = conn.CreateCommand ();
+ cmd.CommandText = "select id, fname, id + 20 as plustwenty from employee";
+ cmd.Prepare ();
+ reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#E:");
+ Assert.AreEqual (3, schema.Rows.Count, "#E:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#E:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#E:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#E:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#E:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#E:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#E:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#E:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#E:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#E:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#E:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#E:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#E:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#E:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#E:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#E:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#E:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#E:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#E:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#E:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#E:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#E:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#E:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#E:IsUnique_IsNull");
+ Assert.AreEqual (true, pkRow ["IsUnique"], "#E:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#E:IsKey_IsNull");
+ Assert.AreEqual (true, pkRow ["IsKey"], "#E:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#E:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#E:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#E:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#E:BaseSchemaName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#E:BaseCatalogName_IsNull");
+ Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#E:BaseCatalogName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#E:BaseTableName_IsNull");
+ Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#E:BaseTableName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#E:BaseColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#E:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#F:");
+ Assert.AreEqual (3, schema.Rows.Count, "#F:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#F:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#F:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#F:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#F:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#F:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#F:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#F:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#F:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#F:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#F:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#F:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#F:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#F:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#F:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#F:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#F:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#F:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#F:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#F:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#F:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#F:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#F:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#F:IsUnique_IsNull");
+ Assert.AreEqual (false, pkRow ["IsUnique"], "#F:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#F:IsKey_IsNull");
+ Assert.AreEqual (false, pkRow ["IsKey"], "#F:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#F:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#F:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#F:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#F:BaseSchemaName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#F:BaseCatalogName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#F:BaseCatalogName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#F:BaseTableName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#F:BaseTableName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#F:BaseColumnName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#F:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader (CommandBehavior.KeyInfo);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#G:");
+ Assert.AreEqual (3, schema.Rows.Count, "#G:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#G:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#G:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#G:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#G:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#G:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#G:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#G:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#G:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#G:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#G:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#G:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#G:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#G:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#G:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#G:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#G:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#G:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#G:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#G:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#G:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#G:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#G:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#G:IsUnique_IsNull");
+ Assert.AreEqual (true, pkRow ["IsUnique"], "#G:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#G:IsKey_IsNull");
+ Assert.AreEqual (true, pkRow ["IsKey"], "#G:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#G:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#G:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#G:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#G:BaseSchemaName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#G:BaseCatalogName_IsNull");
+ Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#G:BaseCatalogName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#G:BaseTableName_IsNull");
+ Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#G:BaseTableName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#G:BaseColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#G:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader ();
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#H:");
+ Assert.AreEqual (3, schema.Rows.Count, "#H:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#H:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#H:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#H:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#H:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#H:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#H:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#H:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#H:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#H:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#H:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#H:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#H:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#H:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#H:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#H:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#H:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#H:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#H:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#H:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#H:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#H:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#H:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#H:IsUnique_IsNull");
+ Assert.AreEqual (false, pkRow ["IsUnique"], "#H:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#H:IsKey_IsNull");
+ Assert.AreEqual (false, pkRow ["IsKey"], "#H:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#H:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#H:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#H:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#H:BaseSchemaName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#H:BaseCatalogName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#H:BaseCatalogName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#H:BaseTableName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#H:BaseTableName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#H:BaseColumnName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#H:BaseColumnName_Value");
+
+ cmd.CommandText = "select id, fname, id + 20 as plustwenty from employee where id = ?";
+ IDbDataParameter param = cmd.CreateParameter ();
+ cmd.Parameters.Add (param);
+ param.DbType = DbType.Int32;
+ param.Value = 2;
+ reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#I:");
+ Assert.AreEqual (3, schema.Rows.Count, "#I:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#I:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#I:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#I:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#I:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#I:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#I:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#I:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#I:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#I:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#I:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#I:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#I:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#I:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#I:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#I:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#I:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#I:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#I:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#I:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#I:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#I:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#I:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#I:IsUnique_IsNull");
+ Assert.AreEqual (true, pkRow ["IsUnique"], "#I:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#I:IsKey_IsNull");
+ Assert.AreEqual (true, pkRow ["IsKey"], "#I:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#I:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#I:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#I:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#I:BaseSchemaName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#I:BaseCatalogName_IsNull");
+ Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#I:BaseCatalogName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#I:BaseTableName_IsNull");
+ Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#I:BaseTableName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#I:BaseColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#I:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#J:");
+ Assert.AreEqual (3, schema.Rows.Count, "#J:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#J:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#J:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#J:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#J:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#J:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#J:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#J:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#J:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#J:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#J:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#J:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#J:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#J:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#J:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#J:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#J:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#J:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#J:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#J:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#J:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#J:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#J:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#J:IsUnique_IsNull");
+ Assert.AreEqual (false, pkRow ["IsUnique"], "#J:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#J:IsKey_IsNull");
+ Assert.AreEqual (false, pkRow ["IsKey"], "#J:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#J:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#J:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#J:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#J:BaseSchemaName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#J:BaseCatalogName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#J:BaseCatalogName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#J:BaseTableName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#J:BaseTableName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#J:BaseColumnName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#J:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader (CommandBehavior.KeyInfo);
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#K:");
+ Assert.AreEqual (3, schema.Rows.Count, "#K:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#K:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#K:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#K:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#K:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#K:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#K:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#K:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#K:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#K:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#K:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#K:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#K:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#K:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#K:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#K:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#K:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#K:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#K:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#K:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#K:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#K:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#K:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#K:IsUnique_IsNull");
+ Assert.AreEqual (true, pkRow ["IsUnique"], "#K:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#K:IsKey_IsNull");
+ Assert.AreEqual (true, pkRow ["IsKey"], "#K:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#K:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#K:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#K:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#K:BaseSchemaName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#K:BaseCatalogName_IsNull");
+ Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#K:BaseCatalogName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#K:BaseTableName_IsNull");
+ Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#K:BaseTableName_Value");
+ Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#K:BaseColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#K:BaseColumnName_Value");
+
+ reader = cmd.ExecuteReader ();
+ schema = reader.GetSchemaTable ();
+ reader.Close ();
+
+ AssertSchemaTableStructure (schema, "#L:");
+ Assert.AreEqual (3, schema.Rows.Count, "#L:RowCount");
+ pkRow = schema.Select ("ColumnName = 'id'") [0];
+ Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#L:ColumnName_IsNull");
+ Assert.AreEqual ("id", pkRow ["ColumnName"], "#L:ColumnName_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#L:ColumnOrdinal_IsNull");
+ Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#L:ColumnOrdinal_Value");
+ Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#L:ColumnSize_IsNull");
+ Assert.AreEqual (4, pkRow ["ColumnSize"], "#L:ColumnSize_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#L:NumericPrecision_IsNull");
+ Assert.AreEqual (10, pkRow ["NumericPrecision"], "#L:NumericPrecision_Value");
+ Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#L:NumericScale_IsNull");
+ Assert.AreEqual (0, pkRow ["NumericScale"], "#L:NumericScale_Value");
+ Assert.IsFalse (pkRow.IsNull ("DataType"), "#L:DataType_IsNull");
+ Assert.AreEqual (typeof (int), pkRow ["DataType"], "#L:DataType_Value");
+ Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#L:ProviderType_IsNull");
+ Assert.AreEqual (10, pkRow ["ProviderType"], "#L:ProviderType_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsLong"), "#L:IsLong_IsNull");
+ Assert.AreEqual (false, pkRow ["IsLong"], "#L:IsLong_Value");
+ Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#L:AllowDBNull_IsNull");
+ Assert.AreEqual (false, pkRow ["AllowDBNull"], "#L:AllowDBNull_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#L:IsReadOnly_IsNull");
+ Assert.AreEqual (false, pkRow ["IsReadOnly"], "#L:IsReadOnly_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#L:IsRowVersion_IsNull");
+ Assert.AreEqual (false, pkRow ["IsRowVersion"], "#L:IsRowVersion_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#L:IsUnique_IsNull");
+ Assert.AreEqual (false, pkRow ["IsUnique"], "#L:IsUnique_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsKey"), "#L:IsKey_IsNull");
+ Assert.AreEqual (false, pkRow ["IsKey"], "#L:IsKey_Value");
+ Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#L:IsAutoIncrement_IsNull");
+ Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#L:IsAutoIncrement_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#L:BaseSchemaName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#L:BaseSchemaName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#L:BaseCatalogName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#L:BaseCatalogName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#L:BaseTableName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#L:BaseTableName_Value");
+ Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#L:BaseColumnName_IsNull");
+ Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#L:BaseColumnName_Value");
+ } finally {
+ if (reader != null)
+ reader.Close ();
+ }
+ }
+
[Test]
public void OutputParametersTest ()
{
- IDbConnection conn = ConnectionManager.Singleton.Connection;
+ // MySQL currently does not support output parameters
+ // in its ODBC connector:
+ // http://www.paragon-cs.com/mag/issue3.pdf
+ if (ConnectionManager.Singleton.Engine.Type != EngineType.SQLServer)
+ Assert.Ignore ("MySQL does not (yet) support output parameters using ODBC.");
+
+ IDataReader reader = null;
+
try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand cmd = conn.CreateCommand ();
- cmd.CommandText = "call {? = sp_get_age (?,?)}";
+ cmd.CommandText = "{? = CALL sp_get_age (?, ?)}";
- OdbcParameter ret = (OdbcParameter) new OdbcParameter ("ret", OdbcType.Int);
+ OdbcParameter ret = new OdbcParameter ("ret", OdbcType.Int);
cmd.Parameters.Add (ret);
ret.Direction = ParameterDirection.ReturnValue;
- OdbcParameter name = (OdbcParameter) new OdbcParameter ("name", OdbcType.VarChar);
+ OdbcParameter name = new OdbcParameter ("fname", OdbcType.VarChar);
cmd.Parameters.Add (name);
name.Direction = ParameterDirection.Input;
name.Value = "suresh";
- OdbcParameter age = (OdbcParameter) new OdbcParameter ("age", OdbcType.Int);
+ OdbcParameter age = new OdbcParameter ("age", OdbcType.Int);
cmd.Parameters.Add (age);
- name.Direction = ParameterDirection.Output;
+ age.Direction = ParameterDirection.Output;
- IDataReader reader = cmd.ExecuteReader ();
+ reader = cmd.ExecuteReader ();
reader.Close ();
- Assert.AreEqual (true, ((int) ret.Value) > 0, "#1");
+
+ /* FIXME: we don't support output/return parameters */
+ if (!RunningOnMono) {
+ Assert.IsTrue (((int) (age.Value)) > 0, "#1");
+ Assert.IsTrue (((int) ret.Value) > 0, "#2");
+ }
} finally {
- ConnectionManager.Singleton.CloseConnection ();
+ if (reader != null)
+ reader.Close ();
}
}
+
[Test]
public void LongTextTest ()
{
- IDbConnection conn = new OdbcConnection (
- ConnectionManager.Singleton.ConnectionString);
- IDataReader rdr = null;
+ IDataReader reader = null;
+
try {
- conn.Open ();
- IDbCommand cmd = conn.CreateCommand ();
- cmd.CommandText = "Select type_text";
- cmd.CommandText += " from string_family where id=3";
-
- rdr = cmd.ExecuteReader ();
- rdr.Read ();
- rdr.GetValue (0);
+ cmd.CommandText = "Select type_text from string_family where id=2";
+
+ reader = cmd.ExecuteReader ();
+ reader.Read ();
+ reader.GetValue (0);
}finally {
- if (rdr != null)
- rdr.Close ();
- conn.Close ();
+ if (reader != null)
+ reader.Close ();
}
}
[Test]
public void Bug82135Test ()
{
- IDbConnection conn = new OdbcConnection (
- ConnectionManager.Singleton.ConnectionString);
- try {
- conn.Open ();
- OdbcCommand cmd = new OdbcCommand ("create table odbcnodatatest (ID int not null, Val1 text)",
- (OdbcConnection) conn);
- cmd.ExecuteNonQuery ();
- cmd = new OdbcCommand ("delete from odbcnodatatest", (OdbcConnection) conn);
- Assert.AreEqual (0, cmd.ExecuteNonQuery ());
- cmd = new OdbcCommand ("drop table odbcnodatatest", (OdbcConnection) conn);
- cmd.ExecuteNonQuery ();
- }finally {
- conn.Close ();
- }
- }
-
- private static void DoExecuteNonQuery (OdbcConnection conn, string sql) {
- OdbcCommand cmd = new OdbcCommand (sql, conn);
- cmd.ExecuteNonQuery();
- }
-
- private static void DoExecuteScalar(OdbcConnection conn, string sql) {
- OdbcCommand cmd = new OdbcCommand (sql, conn);
- cmd.ExecuteScalar();
+ const string drop_table = "drop table odbcnodatatest";
+
+ // cleanup in case of previously failed test
+ DBHelper.ExecuteNonQuery (conn, drop_table);
+
+ cmd = new OdbcCommand ("create table odbcnodatatest (ID int not null, Val1 text)",
+ conn);
+ cmd.ExecuteNonQuery ();
+ cmd = new OdbcCommand ("delete from odbcnodatatest", conn);
+ Assert.AreEqual (0, cmd.ExecuteNonQuery ());
+
+ // cleanup
+ cmd = new OdbcCommand (drop_table, conn);
+ cmd.ExecuteNonQuery ();
}
[Test]
public void Bug82560Test ()
{
- IDbConnection conn = new OdbcConnection (
- ConnectionManager.Singleton.ConnectionString);
- try {
- conn.Open ();
- DoExecuteNonQuery ((OdbcConnection) conn, "CREATE TABLE odbc_alias_test" +
- "(ifld INT NOT NULL PRIMARY KEY, sfld VARCHAR(20))");
- DoExecuteNonQuery ((OdbcConnection) conn, "INSERT INTO odbc_alias_test" +
- "(ifld, sfld) VALUES (1, '1111')");
- DoExecuteScalar ((OdbcConnection) conn, "SELECT A.ifld FROM odbc_alias_test " +
- "A WHERE A.ifld = 1");
- DoExecuteNonQuery ((OdbcConnection) conn, "DROP TABLE odbc_alias_test");
- }finally {
- conn.Close ();
- }
+ string drop_table = "DROP TABLE odbc_alias_test";
+
+ // cleanup in case of previously failed test
+ DBHelper.ExecuteNonQuery (conn, drop_table);
+
+ DoExecuteNonQuery (conn, "CREATE TABLE odbc_alias_test" +
+ "(ifld INT NOT NULL PRIMARY KEY, sfld VARCHAR(20))");
+ DoExecuteNonQuery (conn, "INSERT INTO odbc_alias_test" +
+ "(ifld, sfld) VALUES (1, '1111')");
+ DoExecuteScalar (conn, "SELECT A.ifld FROM odbc_alias_test " +
+ "A WHERE A.ifld = 1");
+ DoExecuteNonQuery (conn, drop_table);
}
[Test]
public void FindZeroInToStringTest ()
{
- IDbConnection conn = ConnectionManager.Singleton.Connection;
+ if (ConnectionManager.Singleton.Engine.Type != EngineType.MySQL)
+ Assert.Ignore ("Only applies to MySQL.");
+
IDataReader reader = null;
+
try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandType = CommandType.Text;
- OdbcCmd.CommandText = "Drop table foo";
- try {
- OdbcCmd.ExecuteNonQuery ();
-#if NET_2_0
- } catch (Exception e) {
-#else
- } catch (OdbcException e) {
-#endif
- Assert.Fail ("Exception thrown: " + e.Message);
- }
// Create table
- OdbcCmd.CommandText = "Create table foo ( bar long varchar )";
- OdbcCmd.ExecuteNonQuery();
+ cmd.CommandText = "Create table foo ( bar long varchar )";
+ cmd.ExecuteNonQuery();
+ cmd.Dispose ();
// Insert a record into foo
- OdbcCmd.CommandText = "Insert into foo (bar) values ( '"
+ cmd = conn.CreateCommand ();
+ cmd.CommandText = "Insert into foo (bar) values ( '"
+ "This string has more than 255 characters"
+ "This string has more than 255 characters"
+ "This string has more than 255 characters"
@@ -192,19 +1030,24 @@ namespace MonoTests.System.Data
+ "This string has more than 255 characters"
+ "This string has more than 255 characters"
+ "' )";
- OdbcCmd.ExecuteNonQuery();
-
+ cmd.ExecuteNonQuery();
+ cmd.Dispose ();
+
// Now, get the record back - try and read it two different ways.
- OdbcCmd.CommandText = "SELECT bar FROM foo" ;
-
- reader = OdbcCmd.ExecuteReader ();
+ cmd = conn.CreateCommand ();
+ cmd.CommandText = "SELECT bar FROM foo" ;
+ reader = cmd.ExecuteReader ();
string readAsString = "";
while (reader.Read ()) {
readAsString = reader[0].ToString();
}
reader.Close();
+ cmd.Dispose ();
+
// Now, read it using GetBytes
- reader = OdbcCmd.ExecuteReader ();
+ cmd = conn.CreateCommand ();
+ cmd.CommandText = "SELECT bar FROM foo";
+ reader = cmd.ExecuteReader ();
byte[] buffer = new byte [2048];
long total = 0;
while (reader.Read ()) {
@@ -217,248 +1060,111 @@ namespace MonoTests.System.Data
} finally {
if (reader != null)
reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
+ DBHelper.ExecuteNonQuery (conn, "Drop table foo");
}
}
[Test]
public void Bug332404Test ()
{
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- try {
- ConnectionManager.Singleton.OpenConnection ();
-
- OdbcCommand TempCmd;
+ if (ConnectionManager.Singleton.Engine.Type != EngineType.MySQL)
+ Assert.Ignore ("Only applies to MySQL.");
- TempCmd = new OdbcCommand ("DROP TABLE IF EXISTS odbc_test");
- TempCmd.Connection = (OdbcConnection) conn;
- TempCmd.ExecuteNonQuery ();
+ cmd = new OdbcCommand ("DROP TABLE IF EXISTS odbc_test");
+ cmd.Connection = conn;
+ cmd.ExecuteNonQuery ();
- TempCmd = new OdbcCommand ("CREATE TABLE odbc_test (id_test INTEGER NOT NULL, payload DECIMAL (14,4) NOT NULL)");
- TempCmd.Connection = (OdbcConnection) conn;
+ cmd = new OdbcCommand ("CREATE TABLE odbc_test (id_test INTEGER NOT NULL, payload DECIMAL (14,4) NOT NULL)");
+ cmd.Connection = conn;
+ cmd.ExecuteNonQuery ();
- TempCmd.ExecuteNonQuery ();
+ cmd = new OdbcCommand ("INSERT INTO odbc_test (id_test, payload) VALUES (1, 1.23456789)");
+ cmd.Connection = conn;
+ cmd.ExecuteNonQuery ();
- TempCmd = new OdbcCommand ("INSERT INTO odbc_test (id_test, payload) VALUES (1, 1.23456789)");
- TempCmd.Connection = (OdbcConnection) conn;
- TempCmd.ExecuteNonQuery ();
+ OdbcDataAdapter Adaptador = new OdbcDataAdapter ();
- OdbcDataAdapter Adaptador = new OdbcDataAdapter ();
+ DataSet Lector = new DataSet ();
- DataSet Lector = new DataSet ();
+ Adaptador.SelectCommand = new OdbcCommand ("SELECT * FROM odbc_test WHERE id_test=1", (OdbcConnection) conn);
+ Adaptador.Fill (Lector);
+ Assert.AreEqual (Lector.Tables[0].Rows[0]["payload"], 1.2346);
+ }
- Adaptador.SelectCommand = new OdbcCommand ("SELECT * FROM odbc_test WHERE id_test=1", (OdbcConnection) conn);
- Adaptador.Fill (Lector);
- Assert.AreEqual (Lector.Tables[0].Rows[0]["payload"], 1.2346);
- } finally {
- ConnectionManager.Singleton.CloseConnection ();
- }
- }
[Test]
public void Bug332400Test ()
{
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- OdbcCommand TempCmd;
+ if (ConnectionManager.Singleton.Engine.Type != EngineType.MySQL)
+ Assert.Ignore ("Only applies to MySQL.");
- TempCmd = new OdbcCommand("DROP TABLE IF EXISTS blob_test");
- TempCmd.Connection = (OdbcConnection) conn;
- TempCmd.ExecuteNonQuery();
+ cmd = new OdbcCommand ("DROP TABLE IF EXISTS blob_test");
+ cmd.Connection = conn;
+ cmd.ExecuteNonQuery ();
- TempCmd = new OdbcCommand("CREATE TABLE blob_test (id_test INTEGER NOT NULL, payload LONGBLOB NOT NULL)");
- TempCmd.Connection = (OdbcConnection) conn;
- TempCmd.ExecuteNonQuery();
+ cmd = new OdbcCommand ("CREATE TABLE blob_test (id_test INTEGER NOT NULL, payload LONGBLOB NOT NULL)");
+ cmd.Connection = conn;
+ cmd.ExecuteNonQuery ();
- TempCmd = new OdbcCommand("INSERT INTO blob_test (id_test, payload) VALUES (1, 'test')");
- TempCmd.Connection = (OdbcConnection) conn;
- TempCmd.ExecuteNonQuery();
+ cmd = new OdbcCommand ("INSERT INTO blob_test (id_test, payload) VALUES (1, 'test')");
+ cmd.Connection = conn;
+ cmd.ExecuteNonQuery ();
- OdbcDataAdapter Adaptador = new OdbcDataAdapter();
- DataSet Lector = new DataSet();
-
- Adaptador.SelectCommand = new OdbcCommand("SELECT * FROM blob_test WHERE id_test=1", (OdbcConnection) conn);
- Adaptador.Fill(Lector);
- } finally {
- ConnectionManager.Singleton.CloseConnection ();
- }
- }
+ OdbcDataAdapter Adaptador = new OdbcDataAdapter();
+ DataSet Lector = new DataSet();
-#if NET_2_0
- [Test]
- public void GetDataTypeNameTest ()
- {
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- Assert.AreEqual ("integer", reader.GetDataTypeName (0), "#1 GetDataTypeName should return integer not Int");
- Assert.AreEqual ("varchar", reader.GetDataTypeName (2), "#2 GetDataTypeName should return varchar not VarChar");
- Assert.AreEqual ("datetime", reader.GetDataTypeName (4), "#3 GetDataTypeName should return datetime not DateTime");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
- }
+ Adaptador.SelectCommand = new OdbcCommand("SELECT * FROM blob_test WHERE id_test=1", (OdbcConnection) conn);
+ Adaptador.Fill(Lector);
}
- [Test]
- public void GetDataTypeNameIndexOutOfRangeExceptionTest ()
+ static void DoExecuteNonQuery (OdbcConnection conn, string sql)
{
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- try {
- /*string tmp = */reader.GetDataTypeName (6);
- } catch (IndexOutOfRangeException) {
- return;
- } Assert.Fail ("Expected Exception IndexOutOfRangeException not thrown");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
- }
+ IDbCommand cmd = new OdbcCommand (sql, conn);
+ cmd.ExecuteNonQuery ();
}
- [Test]
- public void GetOrdinalTest ()
+ static void DoExecuteScalar (OdbcConnection conn, string sql)
{
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- Assert.AreEqual (0, reader.GetOrdinal ("id"), "#1 First column should be id");
- Assert.AreEqual (1, reader.GetOrdinal ("fname"), "#2 Second column should fname");
- Assert.AreEqual (2, reader.GetOrdinal ("lname"), "#3 Third column should lname");
- Assert.AreEqual (3, reader.GetOrdinal ("dob"), "#4 Fourth column should dob");
- Assert.AreEqual (4, reader.GetOrdinal ("doj"), "#5 Fifth column should doj");
- Assert.AreEqual (5, reader.GetOrdinal ("email"), "#6 Sixth column should email");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
- }
+ IDbCommand cmd = new OdbcCommand (sql, conn);
+ cmd.ExecuteScalar ();
}
- [Test]
- public void GetOrdinalIndexOutOfRangeExceptionTest ()
+ static void AssertSchemaTableStructure (DataTable schemaTable, string prefix)
{
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- try {
- /*int ord = */reader.GetOrdinal ("non_existing_column");
- } catch (IndexOutOfRangeException){
- return;
- } Assert.Fail("Expected Exception IndexOutOfRangeException not thrown");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
- }
- }
+ object [] [] columns = {
+ new object [] { "ColumnName", typeof (string) },
+ new object [] { "ColumnOrdinal", typeof (int) },
+ new object [] { "ColumnSize", typeof (int) },
+ new object [] { "NumericPrecision", typeof (short) },
+ new object [] { "NumericScale", typeof (short) },
+ new object [] { "DataType", typeof (object) },
+ new object [] { "ProviderType", typeof (int) },
+ new object [] { "IsLong", typeof (bool) },
+ new object [] { "AllowDBNull", typeof (bool) },
+ new object [] { "IsReadOnly", typeof (bool) },
+ new object [] { "IsRowVersion", typeof (bool) },
+ new object [] { "IsUnique", typeof (bool) },
+ new object [] { "IsKey", typeof (bool) },
+ new object [] { "IsAutoIncrement", typeof (bool) },
+ new object [] { "BaseSchemaName", typeof (string) },
+ new object [] { "BaseCatalogName", typeof (string) },
+ new object [] { "BaseTableName", typeof (string) },
+ new object [] { "BaseColumnName", typeof (string) }
+ };
+ Assert.AreEqual (columns.Length, schemaTable.Columns.Count, prefix);
- [Test]
- public void GetFieldTypeTest ()
- {
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- Assert.AreEqual (typeof(int), reader.GetFieldType (0), "#1 Field type is not Integer");
- Assert.AreEqual (typeof(string), reader.GetFieldType (2), "#2 Field type is not Varchar");
- Assert.AreEqual (typeof(DateTime), reader.GetFieldType (4), "#3 Field type is not DateTime");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
- }
- }
-
- [Test]
- public void GetFieldTypeIndexOutOfRangeExceptionTest ()
- {
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- try {
- /*String tmp = */reader.GetFieldType (6).ToString ();
- } catch (IndexOutOfRangeException){
- return;
- } Assert.Fail("Expected Exception IndexOutOfRangeException not thrown");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
- }
- }
-
- [Test]
- public void GetNameTest ()
- {
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- Assert.AreEqual ("id", reader.GetName (0), "#1 First column is not id");
- Assert.AreEqual ("fname", reader.GetName (1), "#2 Second column is not fname");
- Assert.AreEqual ("lname", reader.GetName (2), "#3 Third column is not lname");
- Assert.AreEqual ("dob", reader.GetName (3), "#4 Fourth column is not dob");
- Assert.AreEqual ("doj", reader.GetName (4), "#5 Fifth column is not doj");
- Assert.AreEqual ("email", reader.GetName (5), "#6 Sixth column is not email");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
+ for (int i = 0; i < columns.Length; i++) {
+ DataColumn col = schemaTable.Columns [i];
+ Assert.IsTrue (col.AllowDBNull, prefix + "AllowDBNull (" + i + ")");
+ Assert.AreEqual (columns [i] [0], col.ColumnName, prefix + "ColumnName (" + i + ")");
+ Assert.AreEqual (columns [i] [1], col.DataType, prefix + "DataType (" + i + ")");
}
}
- [Test]
- public void GetNameIndexOutOfRangeExceptionTest ()
- {
- IDbConnection conn = ConnectionManager.Singleton.Connection;
- IDataReader reader = null;
- try {
- ConnectionManager.Singleton.OpenConnection ();
- IDbCommand OdbcCmd = conn.CreateCommand ();
- OdbcCmd.CommandText = "SELECT * FROM employee WHERE lname='kumar'";
- reader = OdbcCmd.ExecuteReader ();
- try {
- /*String tmp = */reader.GetName (6);
- } catch (IndexOutOfRangeException){
- return;
- } Assert.Fail("Expected Exception IndexOutOfRangeException not thrown");
- } finally {
- if (reader != null)
- reader.Close ();
- ConnectionManager.Singleton.CloseConnection ();
+ static bool RunningOnMono {
+ get {
+ return (Type.GetType ("System.MonoType", false) != null);
}
}
-#endif
}
}