mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
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
900 lines
34 KiB
C#
900 lines
34 KiB
C#
// OdbcCommandBuilderTest.cs - NUnit Test Cases for testing the
|
||
// OdbcCommandBuilder Test.
|
||
//
|
||
// Authors:
|
||
// Sureshkumar T ([email protected])
|
||
//
|
||
// Copyright (c) 2004 Novell Inc., and the individuals listed on the
|
||
// ChangeLog entries.
|
||
//
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person
|
||
// obtaining a copy of this software and associated documentation
|
||
// files (the "Software"), to deal in the Software without
|
||
// restriction, including without limitation the rights to use, copy,
|
||
// modify, merge, publish, distribute, sublicense, and/or sell copies
|
||
// of the Software, and to permit persons to whom the Software is
|
||
// furnished to do so, subject to the following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be
|
||
// included in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
// SOFTWARE.
|
||
|
||
using System;
|
||
using System.Data;
|
||
using System.Data.Common;
|
||
using System.Data.Odbc;
|
||
using Mono.Data;
|
||
|
||
using NUnit.Framework;
|
||
|
||
namespace MonoTests.System.Data
|
||
{
|
||
[TestFixture]
|
||
[Category ("odbc")]
|
||
public class OdbcCommandBuilderTest
|
||
{
|
||
[Test]
|
||
public void GetInsertCommandTest ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb;
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetInsertCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("INSERT INTO employee (id, lname) VALUES (?, ?)",
|
||
cmd.CommandText, "#A1");
|
||
#else
|
||
Assert.AreEqual ("INSERT INTO employee( id , lname ) VALUES ( ? , ? )",
|
||
cmd.CommandText, "#A1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#A2");
|
||
AssertInsertParameters (cmd, "#A3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuotePrefix = "\"";
|
||
|
||
cmd = cb.GetInsertCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("INSERT INTO \"employee (\"id, \"lname) VALUES (?, ?)",
|
||
cmd.CommandText, "#B1");
|
||
#else
|
||
Assert.AreEqual ("INSERT INTO \"employee( \"id , \"lname ) VALUES ( ? , ? )",
|
||
cmd.CommandText, "#B1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#B2");
|
||
AssertInsertParameters (cmd, "#B3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuoteSuffix = "´";
|
||
|
||
cmd = cb.GetInsertCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("INSERT INTO employee´ (id´, lname´) VALUES (?, ?)",
|
||
cmd.CommandText, "#C1");
|
||
#else
|
||
Assert.AreEqual ("INSERT INTO employee´( id´ , lname´ ) VALUES ( ? , ? )",
|
||
cmd.CommandText, "#C1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#C2");
|
||
AssertInsertParameters (cmd, "#C3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuotePrefix = "\"";
|
||
cb.QuoteSuffix = "´";
|
||
|
||
cmd = cb.GetInsertCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("INSERT INTO \"employee´ (\"id´, \"lname´) VALUES (?, ?)",
|
||
cmd.CommandText, "#D1");
|
||
#else
|
||
Assert.AreEqual ("INSERT INTO \"employee´( \"id´ , \"lname´ ) VALUES ( ? , ? )",
|
||
cmd.CommandText, "#D1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#D2");
|
||
AssertInsertParameters (cmd, "#D3:");
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void GetInsertCommandTestWithExpression ()
|
||
{
|
||
if (ConnectionManager.Singleton.Engine.Type == EngineType.MySQL)
|
||
Assert.Ignore ("Schema info from MySQL is incomplete");
|
||
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname, id+1 as next_id from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetInsertCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("INSERT INTO employee (id, lname) VALUES (?, ?)",
|
||
cmd.CommandText, "#1");
|
||
#else
|
||
Assert.AreEqual ("INSERT INTO employee( id , lname ) VALUES ( ? , ? )",
|
||
cmd.CommandText, "#1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#2");
|
||
AssertInsertParameters (cmd, "#3:");
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void GetUpdateCommandTest ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname, id+1 as next_id from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetUpdateCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("UPDATE employee SET id = ?, lname = ? WHERE ((id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)))",
|
||
cmd.CommandText, "#A1");
|
||
#else
|
||
Assert.AreEqual ("UPDATE employee SET id = ? , lname = ? WHERE ( (id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)) )",
|
||
cmd.CommandText, "#A1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#A2");
|
||
AssertUpdateParameters (cmd, "#A3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuotePrefix = "\"";
|
||
|
||
cmd = cb.GetUpdateCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("UPDATE \"employee SET \"id = ?, \"lname = ? WHERE ((\"id = ?) AND ((? = 1 AND \"lname IS NULL) OR (\"lname = ?)))",
|
||
cmd.CommandText, "#B1");
|
||
#else
|
||
Assert.AreEqual ("UPDATE \"employee SET \"id = ? , \"lname = ? WHERE ( (\"id = ?) AND ((? = 1 AND \"lname IS NULL) OR (\"lname = ?)) )",
|
||
cmd.CommandText, "#B1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#B2");
|
||
AssertUpdateParameters (cmd, "#B3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuoteSuffix = "´";
|
||
|
||
cmd = cb.GetUpdateCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("UPDATE employee´ SET id´ = ?, lname´ = ? WHERE ((id´ = ?) AND ((? = 1 AND lname´ IS NULL) OR (lname´ = ?)))",
|
||
cmd.CommandText, "#C1");
|
||
#else
|
||
Assert.AreEqual ("UPDATE employee´ SET id´ = ? , lname´ = ? WHERE ( (id´ = ?) AND ((? = 1 AND lname´ IS NULL) OR (lname´ = ?)) )",
|
||
cmd.CommandText, "#C1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#C2");
|
||
AssertUpdateParameters (cmd, "#C3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuotePrefix = "\"";
|
||
cb.QuoteSuffix = "´";
|
||
|
||
cmd = cb.GetUpdateCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("UPDATE \"employee´ SET \"id´ = ?, \"lname´ = ? WHERE ((\"id´ = ?) AND ((? = 1 AND \"lname´ IS NULL) OR (\"lname´ = ?)))",
|
||
cmd.CommandText, "#D1");
|
||
#else
|
||
Assert.AreEqual ("UPDATE \"employee´ SET \"id´ = ? , \"lname´ = ? WHERE ( (\"id´ = ?) AND ((? = 1 AND \"lname´ IS NULL) OR (\"lname´ = ?)) )",
|
||
cmd.CommandText, "#D1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#D2");
|
||
AssertUpdateParameters (cmd, "#D3:");
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
[Ignore ("FIXME: Auto SQL generation during Update requires a valid SelectCommand")]
|
||
public void GetUpdateCommandDBConcurrencyExceptionTest ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
Assert.IsNotNull (cb);
|
||
|
||
DataRow [] rows = ds.Tables [0].Select ("id=1");
|
||
rows [0] [0] = 6660; // non existent
|
||
ds.Tables [0].AcceptChanges (); // moves 6660 to original value
|
||
rows [0] [0] = 1; // moves 6660 as search key into db table
|
||
|
||
try {
|
||
da.Update (rows);
|
||
Assert.Fail ("#1");
|
||
} catch (DBConcurrencyException ex) {
|
||
// Concurrency violation: the UpdateCommand
|
||
// affected 0 records
|
||
Assert.AreEqual (typeof (DBConcurrencyException), ex.GetType (), "#2");
|
||
Assert.IsNull (ex.InnerException, "#3");
|
||
Assert.IsNotNull (ex.Message, "#4");
|
||
Assert.AreSame (rows [0], ex.Row, "#5");
|
||
#if NET_2_0
|
||
Assert.AreEqual (1, ex.RowCount, "#6");
|
||
#endif
|
||
}
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
#if NET_2_0
|
||
[Test]
|
||
public void GetInsertCommandTest_option_true ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
OdbcCommand cmd = cb.GetInsertCommand (true);
|
||
Assert.AreEqual ("INSERT INTO employee (id, lname) VALUES (?, ?)",
|
||
cmd.CommandText, "#1");
|
||
Assert.AreSame (conn, cmd.Connection, "#2");
|
||
AssertInsertParameters (cmd, "#3:");
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void GetInsertCommandTest_option_false ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
OdbcCommand cmd = cb.GetInsertCommand (false);
|
||
Assert.AreEqual ("INSERT INTO employee (id, lname) VALUES (?, ?)",
|
||
cmd.CommandText, "#1");
|
||
Assert.AreSame (conn, cmd.Connection, "#2");
|
||
AssertInsertParameters (cmd, "#3:");
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void GetUpdateCommandTest_option_true ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
try {
|
||
string selectQuery = "select id, lname, id+1 as next_id from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
OdbcCommand cmd = cb.GetUpdateCommand (true);
|
||
Assert.AreEqual ("UPDATE employee SET id = ?, lname = ? WHERE ((id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)))",
|
||
cmd.CommandText, "#1");
|
||
Assert.AreSame (conn, cmd.Connection, "#2");
|
||
AssertUpdateParameters (cmd, "#3:");
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void GetUpdateCommandTest_option_false ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
try {
|
||
string selectQuery = "select id, lname, id+1 as next_id from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
OdbcCommand cmd = cb.GetUpdateCommand (false);
|
||
Assert.AreEqual ("UPDATE employee SET id = ?, lname = ? WHERE ((id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)))",
|
||
cmd.CommandText, "#1");
|
||
Assert.AreSame (conn, cmd.Connection, "#2");
|
||
AssertUpdateParameters (cmd, "#3:");
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void GetDeleteCommandTest_option_true ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
try {
|
||
string selectQuery = "select id, lname, id+1 as next_id from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
OdbcCommand cmd = cb.GetDeleteCommand (true);
|
||
Assert.AreEqual ("DELETE FROM employee WHERE ((id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)))",
|
||
cmd.CommandText, "#1");
|
||
Assert.AreSame (conn, cmd.Connection, "#2");
|
||
AssertDeleteParameters (cmd, "#3:");
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void GetDeleteCommandTest_option_false ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
try {
|
||
string selectQuery = "select id, lname, id+1 as next_id from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
OdbcCommand cmd = cb.GetDeleteCommand (false);
|
||
Assert.AreEqual ("DELETE FROM employee WHERE ((id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)))",
|
||
cmd.CommandText, "#1");
|
||
Assert.AreSame (conn, cmd.Connection, "#2");
|
||
AssertDeleteParameters (cmd, "#3:");
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
#endif
|
||
|
||
[Test]
|
||
public void GetDeleteCommandTest ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname, id+1 as next_id from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
Assert.AreEqual (1, ds.Tables.Count);
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetDeleteCommand ();
|
||
|
||
#if NET_2_0
|
||
Assert.AreEqual ("DELETE FROM employee WHERE ((id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)))",
|
||
cmd.CommandText, "#A1");
|
||
#else
|
||
Assert.AreEqual ("DELETE FROM employee WHERE ( (id = ?) AND ((? = 1 AND lname IS NULL) OR (lname = ?)) )",
|
||
cmd.CommandText, "#A1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#A2");
|
||
AssertDeleteParameters (cmd, "#A3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuotePrefix = "\"";
|
||
|
||
cmd = cb.GetDeleteCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("DELETE FROM \"employee WHERE ((\"id = ?) AND ((? = 1 AND \"lname IS NULL) OR (\"lname = ?)))",
|
||
cmd.CommandText, "#B1");
|
||
#else
|
||
Assert.AreEqual ("DELETE FROM \"employee WHERE ( (\"id = ?) AND ((? = 1 AND \"lname IS NULL) OR (\"lname = ?)) )",
|
||
cmd.CommandText, "#B1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#B2");
|
||
AssertDeleteParameters (cmd, "#B3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuoteSuffix = "´";
|
||
|
||
cmd = cb.GetDeleteCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("DELETE FROM employee´ WHERE ((id´ = ?) AND ((? = 1 AND lname´ IS NULL) OR (lname´ = ?)))",
|
||
cmd.CommandText, "#C1");
|
||
#else
|
||
Assert.AreEqual ("DELETE FROM employee´ WHERE ( (id´ = ?) AND ((? = 1 AND lname´ IS NULL) OR (lname´ = ?)) )",
|
||
cmd.CommandText, "#C1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#C2");
|
||
AssertDeleteParameters (cmd, "#C3:");
|
||
|
||
cb = new OdbcCommandBuilder (da);
|
||
cb.QuotePrefix = "\"";
|
||
cb.QuoteSuffix = "´";
|
||
|
||
cmd = cb.GetDeleteCommand ();
|
||
#if NET_2_0
|
||
Assert.AreEqual ("DELETE FROM \"employee´ WHERE ((\"id´ = ?) AND ((? = 1 AND \"lname´ IS NULL) OR (\"lname´ = ?)))",
|
||
cmd.CommandText, "#D1");
|
||
#else
|
||
Assert.AreEqual ("DELETE FROM \"employee´ WHERE ( (\"id´ = ?) AND ((? = 1 AND \"lname´ IS NULL) OR (\"lname´ = ?)) )",
|
||
cmd.CommandText, "#D1");
|
||
#endif
|
||
Assert.AreSame (conn, cmd.Connection, "#D2");
|
||
AssertDeleteParameters (cmd, "#D3:");
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
#if NET_2_0
|
||
[Ignore ("QuoteSuffix and QuotePrefix are now in DbCommandBuilder, while commands are in implementation classes. Result: we cannot perform this check until we refactor this.")]
|
||
#endif
|
||
public void QuotePrefix_DeleteCommand_Generated ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetDeleteCommand ();
|
||
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#1");
|
||
try {
|
||
cb.QuotePrefix = "";
|
||
Assert.Fail ("#2");
|
||
} catch (InvalidOperationException ex) {
|
||
// The QuotePrefix and QuoteSuffix properties
|
||
// cannot be changed once an Insert, Update, or
|
||
// Delete command has been generated
|
||
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
|
||
Assert.IsNull (ex.InnerException, "#4");
|
||
Assert.IsNotNull (ex.Message, "#5");
|
||
}
|
||
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#6");
|
||
cb.RefreshSchema ();
|
||
cb.QuotePrefix = "";
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
#if NET_2_0
|
||
[Ignore ("QuoteSuffix and QuotePrefix are now in DbCommandBuilder, while commands are in implementation classes. Result: we cannot perform this check until we refactor this.")]
|
||
#endif
|
||
public void QuotePrefix_InsertCommand_Generated ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetInsertCommand ();
|
||
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#1");
|
||
try {
|
||
cb.QuotePrefix = "";
|
||
Assert.Fail ("#2");
|
||
} catch (InvalidOperationException ex) {
|
||
// The QuotePrefix and QuoteSuffix properties
|
||
// cannot be changed once an Insert, Update, or
|
||
// Delete command has been generated
|
||
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
|
||
Assert.IsNull (ex.InnerException, "#4");
|
||
Assert.IsNotNull (ex.Message, "#5");
|
||
}
|
||
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#6");
|
||
cb.RefreshSchema ();
|
||
cb.QuotePrefix = "";
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
#if NET_2_0
|
||
[Ignore ("QuoteSuffix and QuotePrefix are now in DbCommandBuilder, while commands are in implementation classes. Result: we cannot perform this check until we refactor this.")]
|
||
#endif
|
||
public void QuotePrefix_UpdateCommand_Generated ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetUpdateCommand ();
|
||
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#1");
|
||
try {
|
||
cb.QuotePrefix = "";
|
||
Assert.Fail ("#2");
|
||
} catch (InvalidOperationException ex) {
|
||
// The QuotePrefix and QuoteSuffix properties
|
||
// cannot be changed once an Insert, Update, or
|
||
// Delete command has been generated
|
||
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
|
||
Assert.IsNull (ex.InnerException, "#4");
|
||
Assert.IsNotNull (ex.Message, "#5");
|
||
}
|
||
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#6");
|
||
cb.RefreshSchema ();
|
||
cb.QuotePrefix = "";
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
#if NET_2_0
|
||
[Ignore ("QuoteSuffix and QuotePrefix are now in DbCommandBuilder, while commands are in implementation classes. Result: we cannot perform this check until we refactor this.")]
|
||
#endif
|
||
public void QuoteSuffix_DeleteCommand_Generated ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetDeleteCommand ();
|
||
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#1");
|
||
try {
|
||
cb.QuoteSuffix = "";
|
||
Assert.Fail ("#2");
|
||
} catch (InvalidOperationException ex) {
|
||
// The QuotePrefix and QuoteSuffix properties
|
||
// cannot be changed once an Insert, Update, or
|
||
// Delete command has been generated
|
||
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
|
||
Assert.IsNull (ex.InnerException, "#4");
|
||
Assert.IsNotNull (ex.Message, "#5");
|
||
}
|
||
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#6");
|
||
cb.RefreshSchema ();
|
||
cb.QuoteSuffix = "";
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
#if NET_2_0
|
||
[Ignore ("QuoteSuffix and QuotePrefix are now in DbCommandBuilder, while commands are in implementation classes. Result: we cannot perform this check until we refactor this.")]
|
||
#endif
|
||
public void QuoteSuffix_InsertCommand_Generated ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetInsertCommand ();
|
||
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#1");
|
||
try {
|
||
cb.QuoteSuffix = "";
|
||
Assert.Fail ("#2");
|
||
} catch (InvalidOperationException ex) {
|
||
// The QuotePrefix and QuoteSuffix properties
|
||
// cannot be changed once an Insert, Update, or
|
||
// Delete command has been generated
|
||
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
|
||
Assert.IsNull (ex.InnerException, "#4");
|
||
Assert.IsNotNull (ex.Message, "#5");
|
||
}
|
||
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#6");
|
||
cb.RefreshSchema ();
|
||
cb.QuoteSuffix = "";
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
#if NET_2_0
|
||
[Ignore ("QuoteSuffix and QuotePrefix are now in DbCommandBuilder, while commands are in implementation classes. Result: we cannot perform this check until we refactor this.")]
|
||
#endif
|
||
public void QuoteSuffix_UpdateCommand_Generated ()
|
||
{
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
|
||
OdbcCommand cmd = null;
|
||
|
||
try {
|
||
string selectQuery = "select id, lname from employee where id = 3";
|
||
OdbcDataAdapter da = new OdbcDataAdapter (selectQuery, conn);
|
||
DataSet ds = new DataSet ();
|
||
da.Fill (ds, "IntTest");
|
||
|
||
OdbcCommandBuilder cb = new OdbcCommandBuilder (da);
|
||
cmd = cb.GetUpdateCommand ();
|
||
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#1");
|
||
try {
|
||
cb.QuoteSuffix = "";
|
||
Assert.Fail ("#2");
|
||
} catch (InvalidOperationException ex) {
|
||
// The QuotePrefix and QuoteSuffix properties
|
||
// cannot be changed once an Insert, Update, or
|
||
// Delete command has been generated
|
||
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
|
||
Assert.IsNull (ex.InnerException, "#4");
|
||
Assert.IsNotNull (ex.Message, "#5");
|
||
}
|
||
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#6");
|
||
cb.RefreshSchema ();
|
||
cb.QuoteSuffix = "";
|
||
} finally {
|
||
if (cmd != null)
|
||
cmd.Dispose ();
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
|
||
#if NET_2_0
|
||
[Test] // QuoteIdentifier (String, OdbcConnection)
|
||
public void QuoteIdentifier2 ()
|
||
{
|
||
OdbcCommandBuilder cb;
|
||
OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
|
||
ConnectionManager.Singleton.OpenConnection ();
|
||
|
||
string quote_char = ConnectionManager.Singleton.Engine.QuoteCharacter;
|
||
|
||
try {
|
||
cb = new OdbcCommandBuilder ();
|
||
Assert.AreEqual (quote_char + "mono" + quote_char, cb.QuoteIdentifier ("mono", conn), "#A1");
|
||
Assert.AreEqual (quote_char + "Z" + quote_char, cb.QuoteIdentifier ("Z", conn), "#A2");
|
||
Assert.AreEqual (quote_char + "abc" + quote_char, cb.QuoteIdentifier ("abc", conn), "#A3");
|
||
Assert.AreEqual (quote_char + quote_char, cb.QuoteIdentifier (string.Empty, conn), "#A4");
|
||
Assert.AreEqual (quote_char + " " + quote_char, cb.QuoteIdentifier (" ", conn), "#A5");
|
||
Assert.AreEqual (quote_char + "\r" + quote_char, cb.QuoteIdentifier ("\r", conn), "#A6");
|
||
cb.QuoteSuffix = "def";
|
||
Assert.AreEqual (quote_char + "mono" + quote_char, cb.QuoteIdentifier ("mono", conn), "#A7");
|
||
Assert.AreEqual (quote_char + "Z" + quote_char, cb.QuoteIdentifier ("Z", conn), "#A8");
|
||
Assert.AreEqual (quote_char + "abc" + quote_char, cb.QuoteIdentifier ("abc", conn), "#A9");
|
||
Assert.AreEqual (quote_char + quote_char, cb.QuoteIdentifier (string.Empty, conn), "#A10");
|
||
Assert.AreEqual (quote_char + " " + quote_char, cb.QuoteIdentifier (" ", conn), "#A11");
|
||
Assert.AreEqual (quote_char + "\r" + quote_char, cb.QuoteIdentifier ("\r", conn), "#A12");
|
||
|
||
cb = new OdbcCommandBuilder ();
|
||
cb.QuotePrefix = "abc";
|
||
Assert.AreEqual ("abcmono", cb.QuoteIdentifier ("mono", conn), "#B1");
|
||
Assert.AreEqual ("abcZ", cb.QuoteIdentifier ("Z", conn), "#B2");
|
||
Assert.AreEqual ("abcabc", cb.QuoteIdentifier ("abc", conn), "#B3");
|
||
Assert.AreEqual ("abc", cb.QuoteIdentifier (string.Empty, conn), "#B4");
|
||
Assert.AreEqual ("abc ", cb.QuoteIdentifier (" ", conn), "#B5");
|
||
Assert.AreEqual ("abc\r", cb.QuoteIdentifier ("\r", conn), "#B6");
|
||
cb.QuoteSuffix = "def";
|
||
Assert.AreEqual ("abcmonodef", cb.QuoteIdentifier ("mono", conn), "#B7");
|
||
Assert.AreEqual ("abcZdef", cb.QuoteIdentifier ("Z", conn), "#B8");
|
||
Assert.AreEqual ("abcabcdef", cb.QuoteIdentifier ("abc", conn), "#B9");
|
||
Assert.AreEqual ("abcdef", cb.QuoteIdentifier (string.Empty, conn), "#B10");
|
||
Assert.AreEqual ("abc def", cb.QuoteIdentifier (" ", conn), "#B11");
|
||
Assert.AreEqual ("abc\rdef", cb.QuoteIdentifier ("\r", conn), "#B12");
|
||
|
||
cb.QuotePrefix = string.Empty;
|
||
|
||
cb = new OdbcCommandBuilder ();
|
||
cb.QuotePrefix = "X";
|
||
Assert.AreEqual ("Xmono", cb.QuoteIdentifier ("mono", conn), "#D1");
|
||
Assert.AreEqual ("XZ", cb.QuoteIdentifier ("Z", conn), "#D2");
|
||
Assert.AreEqual ("XX", cb.QuoteIdentifier ("X", conn), "#D3");
|
||
Assert.AreEqual ("X", cb.QuoteIdentifier (string.Empty, conn), "#D4");
|
||
Assert.AreEqual ("X ", cb.QuoteIdentifier (" ", conn), "#D5");
|
||
Assert.AreEqual ("X\r", cb.QuoteIdentifier ("\r", conn), "#D6");
|
||
cb.QuoteSuffix = " ";
|
||
Assert.AreEqual ("Xmono ", cb.QuoteIdentifier ("mono", conn), "#D7");
|
||
Assert.AreEqual ("XZ ", cb.QuoteIdentifier ("Z", conn), "#D8");
|
||
Assert.AreEqual ("XX ", cb.QuoteIdentifier ("X", conn), "#D9");
|
||
Assert.AreEqual ("X ", cb.QuoteIdentifier (string.Empty, conn), "#D10");
|
||
Assert.AreEqual ("X ", cb.QuoteIdentifier (" ", conn), "#D11");
|
||
Assert.AreEqual ("X\r ", cb.QuoteIdentifier ("\r", conn), "#D12");
|
||
|
||
cb = new OdbcCommandBuilder ();
|
||
cb.QuotePrefix = " ";
|
||
Assert.AreEqual ("mono", cb.QuoteIdentifier ("mono", conn), "#E1");
|
||
Assert.AreEqual ("Z", cb.QuoteIdentifier ("Z", conn), "#E2");
|
||
Assert.AreEqual ("abc", cb.QuoteIdentifier ("abc", conn), "#E3");
|
||
Assert.AreEqual (string.Empty, cb.QuoteIdentifier (string.Empty, conn), "#E4");
|
||
Assert.AreEqual (" ", cb.QuoteIdentifier (" ", conn), "#E5");
|
||
Assert.AreEqual ("\r", cb.QuoteIdentifier ("\r", conn), "#E6");
|
||
cb.QuoteSuffix = "def";
|
||
Assert.AreEqual ("mono", cb.QuoteIdentifier ("mono", conn), "#E7");
|
||
Assert.AreEqual ("Z", cb.QuoteIdentifier ("Z", conn), "#E8");
|
||
Assert.AreEqual ("abc", cb.QuoteIdentifier ("abc", conn), "#E9");
|
||
Assert.AreEqual (string.Empty, cb.QuoteIdentifier (string.Empty, conn), "#E10");
|
||
Assert.AreEqual (" ", cb.QuoteIdentifier (" ", conn), "#E11");
|
||
Assert.AreEqual ("\r", cb.QuoteIdentifier ("\r", conn), "#E12");
|
||
} finally {
|
||
ConnectionManager.Singleton.CloseConnection ();
|
||
}
|
||
}
|
||
#endif
|
||
|
||
void AssertInsertParameters (OdbcCommand cmd, string prefix)
|
||
{
|
||
Assert.AreEqual (2, cmd.Parameters.Count, prefix + "Count");
|
||
Assert.AreEqual (DbType.Int32, cmd.Parameters [0].DbType, prefix + "DbType (0)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p1", cmd.Parameters [0].ParameterName, prefix + "ParameterName (0)");
|
||
#else
|
||
Assert.AreEqual ("@p1", cmd.Parameters [0].ParameterName, prefix + "ParameterName (0)");
|
||
#endif
|
||
Assert.AreEqual ("id", cmd.Parameters [0].SourceColumn, prefix + "SourceColumn (0)");
|
||
Assert.IsNull (cmd.Parameters [0].Value, prefix + "Value (0)");
|
||
Assert.AreEqual (DbType.AnsiString, cmd.Parameters [1].DbType, prefix + "DbType (1)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p2", cmd.Parameters [1].ParameterName, prefix + "ParameterName (1)");
|
||
#else
|
||
Assert.AreEqual ("@p2", cmd.Parameters [1].ParameterName, prefix + "ParameterName (1)");
|
||
#endif
|
||
Assert.AreEqual ("lname", cmd.Parameters [1].SourceColumn, prefix + "SourceColumn (1)");
|
||
Assert.IsNull (cmd.Parameters [1].Value, prefix + "Value (1)");
|
||
}
|
||
|
||
void AssertUpdateParameters (OdbcCommand cmd, string prefix)
|
||
{
|
||
Assert.AreEqual (5, cmd.Parameters.Count, prefix + "Count");
|
||
Assert.AreEqual (DbType.Int32, cmd.Parameters [0].DbType, prefix + "DbType (0)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p1", cmd.Parameters [0].ParameterName, prefix + "ParameterName (0)");
|
||
#else
|
||
Assert.AreEqual ("@p1", cmd.Parameters [0].ParameterName, prefix + "ParameterName (0)");
|
||
#endif
|
||
Assert.AreEqual ("id", cmd.Parameters [0].SourceColumn, prefix + "SourceColumn (0)");
|
||
Assert.IsNull (cmd.Parameters [0].Value, prefix + "Value (0)");
|
||
Assert.AreEqual (DbType.AnsiString, cmd.Parameters [1].DbType, prefix + "DbType (1)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p2", cmd.Parameters [1].ParameterName, prefix + "ParameterName (1)");
|
||
#else
|
||
Assert.AreEqual ("@p2", cmd.Parameters [1].ParameterName, prefix + "ParameterName (1)");
|
||
#endif
|
||
Assert.AreEqual ("lname", cmd.Parameters [1].SourceColumn, prefix + "SourceColumn (1)");
|
||
Assert.IsNull (cmd.Parameters [1].Value, prefix + "Value (1)");
|
||
Assert.AreEqual (DbType.Int32, cmd.Parameters [2].DbType, prefix + "DbType (2)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p3", cmd.Parameters [2].ParameterName, prefix + "ParameterName (2)");
|
||
#else
|
||
Assert.AreEqual ("@p3", cmd.Parameters [2].ParameterName, prefix + "ParameterName (2)");
|
||
#endif
|
||
Assert.AreEqual ("id", cmd.Parameters [2].SourceColumn, prefix + "SourceColumn (2)");
|
||
Assert.IsNull (cmd.Parameters [2].Value, prefix + "Value (2)");
|
||
Assert.AreEqual (DbType.Int32, cmd.Parameters [3].DbType, prefix + "DbType (3)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p4", cmd.Parameters [3].ParameterName, prefix + "ParameterName (3)");
|
||
Assert.AreEqual ("lname", cmd.Parameters [3].SourceColumn, prefix + "SourceColumn (3)");
|
||
#else
|
||
Assert.AreEqual ("@p4", cmd.Parameters [3].ParameterName, prefix + "ParameterName (3)");
|
||
Assert.AreEqual (string.Empty, cmd.Parameters [3].SourceColumn, prefix + "SourceColumn (3)");
|
||
#endif
|
||
Assert.AreEqual (1, cmd.Parameters [3].Value, prefix + "Value (3)");
|
||
Assert.AreEqual (DbType.AnsiString, cmd.Parameters [4].DbType, prefix + "DbType (4)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p5", cmd.Parameters [4].ParameterName, prefix + "ParameterName (4)");
|
||
#else
|
||
Assert.AreEqual ("@p5", cmd.Parameters [4].ParameterName, prefix + "ParameterName (4)");
|
||
#endif
|
||
Assert.AreEqual ("lname", cmd.Parameters [4].SourceColumn, prefix + "SourceColumn (4)");
|
||
Assert.IsNull (cmd.Parameters [4].Value, prefix + "Value (4)");
|
||
}
|
||
|
||
void AssertDeleteParameters (OdbcCommand cmd, string prefix)
|
||
{
|
||
Assert.AreEqual (3, cmd.Parameters.Count, prefix + "Count");
|
||
Assert.AreEqual (DbType.Int32, cmd.Parameters [0].DbType, prefix + "DbType (0)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p1", cmd.Parameters [0].ParameterName, prefix + "ParameterName (0)");
|
||
#else
|
||
Assert.AreEqual ("@p1", cmd.Parameters [0].ParameterName, prefix + "ParameterName (0)");
|
||
#endif
|
||
Assert.AreEqual ("id", cmd.Parameters [0].SourceColumn, prefix + "SourceColumn (0)");
|
||
Assert.IsNull (cmd.Parameters [0].Value, prefix + "Value (0)");
|
||
Assert.AreEqual (DbType.Int32, cmd.Parameters [1].DbType, prefix + "DbType (1)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p2", cmd.Parameters [1].ParameterName, prefix + "ParameterName (1)");
|
||
Assert.AreEqual ("lname", cmd.Parameters [1].SourceColumn, prefix + "SourceColumn (1)");
|
||
#else
|
||
Assert.AreEqual ("@p2", cmd.Parameters [1].ParameterName, prefix + "ParameterName (1)");
|
||
Assert.AreEqual (string.Empty, cmd.Parameters [1].SourceColumn, prefix + "SourceColumn (1)");
|
||
#endif
|
||
Assert.AreEqual (1, cmd.Parameters [1].Value, prefix + "Value (1)");
|
||
Assert.AreEqual (DbType.AnsiString, cmd.Parameters [2].DbType, prefix + "DbType (2)");
|
||
#if NET_2_0
|
||
Assert.AreEqual ("p3", cmd.Parameters [2].ParameterName, prefix + "ParameterName (2)");
|
||
#else
|
||
Assert.AreEqual ("@p3", cmd.Parameters [2].ParameterName, prefix + "ParameterName (2)");
|
||
#endif
|
||
Assert.AreEqual ("lname", cmd.Parameters [2].SourceColumn, prefix + "SourceColumn (2)");
|
||
Assert.IsNull (cmd.Parameters [2].Value, prefix + "Value (2)");
|
||
}
|
||
|
||
// FIXME: test SetAllValues
|
||
// FIXME: Add tests for examining RowError
|
||
// FIXME: Add test for ContinueUpdateOnError property
|
||
}
|
||
}
|