Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@@ -48,13 +48,13 @@ namespace MonoTests.System.Data.Connected
private static ConnectionManager instance;
private ConnectionHolder<SqlConnection> sql;
private const string OdbcEnvVar = "SYSTEM_DATA_ODBC_V2";
private const string SqlEnvVar = "SYSTEM_DATA_MSSQL_V2";
private const string OdbcEnvVar = "SYSTEM_DATA_ODBC_V3";
private const string SqlEnvVar = "SYSTEM_DATA_MSSQL_V3";
private ConnectionManager ()
{
//Environment.SetEnvironmentVariable(OdbcEnvVar, @"Driver={MySQL ODBC 5.3 Unicode Driver};server=127.0.0.1;uid=sa;pwd=qwerty123;");
//Environment.SetEnvironmentVariable(SqlEnvVar, @"server=127.0.0.1;database=master;user id=sa;password=qwerty123");
//Environment.SetEnvironmentVariable(SqlEnvVar, @"Server=.\SQLEXPRESS;Database=master;User Id=sa;Password=qwerty123;");
// Generate a random db name
DatabaseName = "monotest" + Guid.NewGuid().ToString().Substring(0, 7);
@@ -102,9 +102,12 @@ namespace MonoTests.System.Data.Connected
string connectionString = Environment.GetEnvironmentVariable (envVarName);
if (string.IsNullOrEmpty (connectionString))
return null;
#if MOBILE
connection = new OdbcConnection ();
#else
DbProviderFactory factory = DbProviderFactories.GetFactory ("System.Data.Odbc");
var connection = (OdbcConnection)factory.CreateConnection ();
#endif
var engine = new EngineConfig {
Type = EngineType.MySQL,
@@ -171,8 +174,7 @@ namespace MonoTests.System.Data.Connected
// Split SQL script by "GO" statements
private static IEnumerable<string> SplitSqlStatements(string sqlScript)
{
var statements = Regex.Split(sqlScript,
$@"^[\t ]*GO[\t ]*\d*[\t ]*(?:--.*)?$",
var statements = Regex.Split(sqlScript, @"^\s*GO.*$",
RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
return statements.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim(' ', '\r', '\n'));
}
@@ -247,6 +249,8 @@ namespace MonoTests.System.Data.Connected
EngineConfig = engineConfig;
this.connection = connection;
ConnectionString = connectionString;
if (!ConnectionString.EndsWith(";"))
ConnectionString += ";";
}
public bool IsAzure => ConnectionString.ToLower().Contains("database.windows.net");

View File

@@ -75,20 +75,20 @@ namespace MonoTests.System.Data.Connected.Odbc
AssertInsertParameters (cmd, "#B3:");
cb = new OdbcCommandBuilder (da);
cb.QuoteSuffix = "<EFBFBD>";
cb.QuoteSuffix = "´";
cmd = cb.GetInsertCommand ();
Assert.AreEqual ("INSERT INTO employee<EFBFBD> (id<EFBFBD>, lname<EFBFBD>) VALUES (?, ?)",
Assert.AreEqual ("INSERT INTO employee´ (id´, lname´) VALUES (?, ?)",
cmd.CommandText, "#C1");
Assert.AreSame (conn, cmd.Connection, "#C2");
AssertInsertParameters (cmd, "#C3:");
cb = new OdbcCommandBuilder (da);
cb.QuotePrefix = "\"";
cb.QuoteSuffix = "<EFBFBD>";
cb.QuoteSuffix = "´";
cmd = cb.GetInsertCommand ();
Assert.AreEqual ("INSERT INTO \"employee<EFBFBD> (\"id<EFBFBD>, \"lname<EFBFBD>) VALUES (?, ?)",
Assert.AreEqual ("INSERT INTO \"employee´ (\"id´, \"lname´) VALUES (?, ?)",
cmd.CommandText, "#D1");
Assert.AreSame (conn, cmd.Connection, "#D2");
AssertInsertParameters (cmd, "#D3:");
@@ -158,20 +158,20 @@ namespace MonoTests.System.Data.Connected.Odbc
AssertUpdateParameters (cmd, "#B3:");
cb = new OdbcCommandBuilder (da);
cb.QuoteSuffix = "<EFBFBD>";
cb.QuoteSuffix = "´";
cmd = cb.GetUpdateCommand ();
Assert.AreEqual ("UPDATE employee<EFBFBD> SET id<EFBFBD> = ?, lname<EFBFBD> = ? WHERE ((id<EFBFBD> = ?) AND ((? = 1 AND lname<EFBFBD> IS NULL) OR (lname<EFBFBD> = ?)))",
Assert.AreEqual ("UPDATE employee´ SET id´ = ?, lname´ = ? WHERE ((id´ = ?) AND ((? = 1 AND lname´ IS NULL) OR (lname´ = ?)))",
cmd.CommandText, "#C1");
Assert.AreSame (conn, cmd.Connection, "#C2");
AssertUpdateParameters (cmd, "#C3:");
cb = new OdbcCommandBuilder (da);
cb.QuotePrefix = "\"";
cb.QuoteSuffix = "<EFBFBD>";
cb.QuoteSuffix = "´";
cmd = cb.GetUpdateCommand ();
Assert.AreEqual ("UPDATE \"employee<EFBFBD> SET \"id<EFBFBD> = ?, \"lname<EFBFBD> = ? WHERE ((\"id<EFBFBD> = ?) AND ((? = 1 AND \"lname<EFBFBD> IS NULL) OR (\"lname<EFBFBD> = ?)))",
Assert.AreEqual ("UPDATE \"employee´ SET \"id´ = ?, \"lname´ = ? WHERE ((\"id´ = ?) AND ((? = 1 AND \"lname´ IS NULL) OR (\"lname´ = ?)))",
cmd.CommandText, "#D1");
Assert.AreSame (conn, cmd.Connection, "#D2");
AssertUpdateParameters (cmd, "#D3:");
@@ -385,20 +385,20 @@ namespace MonoTests.System.Data.Connected.Odbc
AssertDeleteParameters (cmd, "#B3:");
cb = new OdbcCommandBuilder (da);
cb.QuoteSuffix = "<EFBFBD>";
cb.QuoteSuffix = "´";
cmd = cb.GetDeleteCommand ();
Assert.AreEqual ("DELETE FROM employee<EFBFBD> WHERE ((id<EFBFBD> = ?) AND ((? = 1 AND lname<EFBFBD> IS NULL) OR (lname<EFBFBD> = ?)))",
Assert.AreEqual ("DELETE FROM employee´ WHERE ((id´ = ?) AND ((? = 1 AND lname´ IS NULL) OR (lname´ = ?)))",
cmd.CommandText, "#C1");
Assert.AreSame (conn, cmd.Connection, "#C2");
AssertDeleteParameters (cmd, "#C3:");
cb = new OdbcCommandBuilder (da);
cb.QuotePrefix = "\"";
cb.QuoteSuffix = "<EFBFBD>";
cb.QuoteSuffix = "´";
cmd = cb.GetDeleteCommand ();
Assert.AreEqual ("DELETE FROM \"employee<EFBFBD> WHERE ((\"id<EFBFBD> = ?) AND ((? = 1 AND \"lname<EFBFBD> IS NULL) OR (\"lname<EFBFBD> = ?)))",
Assert.AreEqual ("DELETE FROM \"employee´ WHERE ((\"id´ = ?) AND ((? = 1 AND \"lname´ IS NULL) OR (\"lname´ = ?)))",
cmd.CommandText, "#D1");
Assert.AreSame (conn, cmd.Connection, "#D2");
AssertDeleteParameters (cmd, "#D3:");
@@ -638,6 +638,7 @@ namespace MonoTests.System.Data.Connected.Odbc
}
[Test] // QuoteIdentifier (String, OdbcConnection)
[Category("NotWorking")] //needs https://github.com/dotnet/corefx/pull/22499
public void QuoteIdentifier2 ()
{
OdbcCommandBuilder cb;

View File

@@ -97,7 +97,8 @@ namespace MonoTests.System.Data.Connected.SqlClient
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNull (cmd.Notification, "#A7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
//needs SqlDependency impl in corefx:
//Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
Assert.IsNotNull (cmd.Parameters, "#A9");
Assert.AreEqual (0, cmd.Parameters.Count, "#A10");
Assert.IsNull (cmd.Site, "#A11");
@@ -127,7 +128,8 @@ namespace MonoTests.System.Data.Connected.SqlClient
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNull (cmd.Notification, "#B7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
//needs SqlDependency impl in corefx:
//Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
Assert.IsNotNull (cmd.Parameters, "#B9");
Assert.AreEqual (0, cmd.Parameters.Count, "#B10");
Assert.IsNull (cmd.Site, "#B11");
@@ -2453,6 +2455,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void NotificationAutoEnlistTest ()
{
cmd = new SqlCommand ();
@@ -2462,6 +2465,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22876
public void BeginExecuteXmlReaderTest ()
{
cmd = new SqlCommand ();
@@ -2474,7 +2478,8 @@ namespace MonoTests.System.Data.Connected.SqlClient
cmd.Connection = conn1;
IAsyncResult result = cmd.BeginExecuteXmlReader ();
XmlReader reader = cmd.EndExecuteXmlReader (result);
//EndExecuteXmlReader is private in corefx https://github.com/dotnet/corefx/issues/22876
XmlReader reader = null;// cmd.EndExecuteXmlReader (result);
while (reader.Read ()) {
if (reader.LocalName.ToString () == "employee")
Assert.AreEqual ("kumar", reader["lname"], "#1 ");
@@ -2483,29 +2488,6 @@ namespace MonoTests.System.Data.Connected.SqlClient
ConnectionManager.Instance.Sql.CloseConnection ();
}
}
[Test]
[Ignore("MS .NET doesn't throw IOE here. TODO: check corefx")]
public void BeginExecuteXmlReaderExceptionTest ()
{
cmd = new SqlCommand ();
try {
SqlConnection conn = new SqlConnection (connectionString);
conn.Open ();
cmd.CommandText = "Select lname from employee where id<2 FOR XML AUTO, XMLDATA";
cmd.Connection = conn;
try {
/*IAsyncResult result = */cmd.BeginExecuteXmlReader ();
} catch (InvalidOperationException) {
Assert.AreEqual (ConnectionManager.Instance.Sql.ConnectionString, connectionString, "#1 Connection string has changed");
return;
}
Assert.Fail ("Expected Exception InvalidOperationException not thrown");
} finally {
ConnectionManager.Instance.Sql.CloseConnection ();
}
}
[Test]
public void SqlCommandDisposeTest ()

View File

@@ -64,6 +64,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void PropertiesTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;");
@@ -75,6 +76,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test]
[Category("NotWorking")] //https://github.com/dotnet/corefx/issues/22474
public void ItemTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;");
@@ -102,6 +104,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test, ExpectedException (typeof (ArgumentException))]
[Category("NotWorking")] //https://github.com/dotnet/corefx/issues/22474
public void InvalidKeyTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;Network=DBMSSOCN");
@@ -110,6 +113,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test]
[Category("NotWorking")] //https://github.com/dotnet/corefx/issues/22474
public void RemoveTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER = localhost ;Network=DBMSSOCN");
@@ -161,6 +165,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void ContextConnectionTest ()
{
builder = new SqlConnectionStringBuilder ();
@@ -171,6 +176,7 @@ namespace MonoTests.System.Data.Connected.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void SettingContextConnectionTest ()
{
builder = new SqlConnectionStringBuilder ();

View File

@@ -162,10 +162,10 @@ namespace MonoTests.System.Data.Connected.SqlClient
// Cannot open database "invalidDB" requested
// by the login. The login failed
Assert.AreEqual (typeof (SqlException), ex.GetType (), "#2");
Assert.AreEqual ((byte) 14, ex.Class, "#3");
Assert.AreEqual ((byte) 11, ex.Class, "#3");
Assert.IsNull (ex.InnerException, "#4");
Assert.IsNotNull (ex.Message, "#5");
Assert.AreEqual (18456, ex.Number, "#7");
Assert.AreEqual (4060, ex.Number, "#7");
Assert.AreEqual ((byte) 1, ex.State, "#8");
} finally {
conn.Close ();
@@ -629,7 +629,6 @@ namespace MonoTests.System.Data.Connected.SqlClient
Assert.AreEqual ("", conn.Database, "#C2");
Assert.AreEqual (8000, conn.PacketSize, "#C3");
Assert.AreEqual (15, conn.ConnectionTimeout, "#C4");
Assert.IsTrue (string.Compare (conn.WorkstationId, Environment.MachineName, true) == 0, "#C5");
}
[Test]
@@ -722,6 +721,17 @@ namespace MonoTests.System.Data.Connected.SqlClient
conn.Close ();
}
[Test]
[Category("NotWorking")] //https://github.com/dotnet/corefx/issues/22871
public void WorkstationId()
{
var connection1 = new SqlConnection (connectionString + ";Workstation Id=Desktop");
var connection2 = new SqlConnection (connectionString);
connection1.Dispose();
Assert.AreEqual (Environment.MachineName, connection1.WorkstationId);
Assert.AreEqual (Environment.MachineName, connection2.WorkstationId);
}
[Test] // bug #412571
public void Dispose ()
{
@@ -740,7 +750,6 @@ namespace MonoTests.System.Data.Connected.SqlClient
Assert.AreEqual (string.Empty, conn.DataSource, "#A5");
Assert.AreEqual (8000, conn.PacketSize, "#A6");
Assert.AreEqual (ConnectionState.Closed, conn.State, "#A7");
Assert.IsTrue (string.Compare (conn.WorkstationId, Environment.MachineName, true) == 0, "#A8");
Assert.AreEqual (2, events.Count, "#A9");
stateChangeArgs = events [0] as StateChangeEventArgs;

View File

@@ -38,6 +38,7 @@ using NUnit.Framework;
namespace MonoTests.System.Data.Odbc
{
[TestFixture]
[Category("NotWorking")] // needs https://github.com/dotnet/corefx/pull/22499
public class OdbcCommandBuilderTest
{
[Test]

View File

@@ -131,6 +131,7 @@ namespace MonoTests.System.Data.Odbc
}
[Test]
[Category("NotWorking")] //GetSchema is not implemented in corefx for ODBC
public void GetSchema_Connection_Closed ()
{
OdbcConnection cn = new OdbcConnection ();

View File

@@ -31,9 +31,8 @@
using System;
using System.Data;
using System.Data.Odbc;
using System.Data.OleDb;
using NUnit.Framework;
using SqlCommand = System.Data.SqlClient.SqlCommand;
namespace MonoTests.System.Data.Odbc
{
@@ -307,7 +306,7 @@ namespace MonoTests.System.Data.Odbc
Assert.IsNull (da.DeleteCommand, "#A3");
try {
da.DeleteCommand = new OleDbCommand ();
da.DeleteCommand = new SqlCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
@@ -364,7 +363,7 @@ namespace MonoTests.System.Data.Odbc
Assert.IsNull (da.InsertCommand, "#A3");
try {
da.InsertCommand = new OleDbCommand ();
da.InsertCommand = new SqlCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
@@ -403,7 +402,7 @@ namespace MonoTests.System.Data.Odbc
Assert.IsNull (da.SelectCommand, "#A3");
try {
da.SelectCommand = new OleDbCommand ();
da.SelectCommand = new SqlCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
@@ -480,7 +479,7 @@ namespace MonoTests.System.Data.Odbc
Assert.IsNull (da.UpdateCommand, "#A3");
try {
da.UpdateCommand = new OleDbCommand ();
da.UpdateCommand = new SqlCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");

View File

@@ -1,199 +0,0 @@
//
// OleDbCommandTest.cs - NUnit Test Cases for testing
// System.Data.OleDb.OleDbCommand
//
// Author:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// Copyright (c) 2007 Gert Driesen
//
// 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.
//
#if !NO_OLEDB
using System.Data;
using System.Data.OleDb;
using NUnit.Framework;
namespace MonoTests.System.Data.OleDb
{
[TestFixture]
public class OleDbCommandTest
{
const string COMMAND_TEXT = "SELECT * FROM Authors";
[Test] // OleDbCommand ()
public void Constructor1 ()
{
OleDbCommand cmd = new OleDbCommand ();
Assert.AreEqual (string.Empty, cmd.CommandText, "#1");
Assert.AreEqual (30, cmd.CommandTimeout, "#2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#3");
Assert.IsNull (cmd.Connection, "#4");
Assert.IsNull (cmd.Container, "#5");
Assert.IsTrue (cmd.DesignTimeVisible, "#6");
Assert.IsNotNull (cmd.Parameters, "#7");
Assert.AreEqual (0, cmd.Parameters.Count, "#8");
Assert.IsNull (cmd.Site, "#9");
Assert.IsNull (cmd.Transaction, "#10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#11");
}
[Test] // OleDbCommand (string)
public void Constructor2 ()
{
OleDbCommand cmd = new OleDbCommand (COMMAND_TEXT);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#A1");
Assert.AreEqual (30, cmd.CommandTimeout, "#A2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#A3");
Assert.IsNull (cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNotNull (cmd.Parameters, "#A7");
Assert.AreEqual (0, cmd.Parameters.Count, "#A8");
Assert.IsNull (cmd.Site, "#A9");
Assert.IsNull (cmd.Transaction, "#A10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#A11");
cmd = new OleDbCommand ((string) null);
Assert.AreEqual (string.Empty, cmd.CommandText, "#B1");
Assert.AreEqual (30, cmd.CommandTimeout, "#B2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#B3");
Assert.IsNull (cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNotNull (cmd.Parameters, "#B7");
Assert.AreEqual (0, cmd.Parameters.Count, "#B8");
Assert.IsNull (cmd.Site, "#B9");
Assert.IsNull (cmd.Transaction, "#B10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#B11");
}
[Test] // OleDbCommand (string, OleDbConnection)
public void Constructor3 ()
{
OleDbConnection conn = new OleDbConnection ();
OleDbCommand cmd;
cmd = new OleDbCommand (COMMAND_TEXT, conn);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#A1");
Assert.AreEqual (30, cmd.CommandTimeout, "#A2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#A3");
Assert.AreSame (conn, cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNotNull (cmd.Parameters, "#A7");
Assert.AreEqual (0, cmd.Parameters.Count, "#A8");
Assert.IsNull (cmd.Site, "#A9");
Assert.IsNull (cmd.Transaction, "#A10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#A11");
cmd = new OleDbCommand ((string) null, conn);
Assert.AreEqual (string.Empty, cmd.CommandText, "#B1");
Assert.AreEqual (30, cmd.CommandTimeout, "#B2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#B3");
Assert.AreSame (conn, cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNotNull (cmd.Parameters, "#B7");
Assert.AreEqual (0, cmd.Parameters.Count, "#B8");
Assert.IsNull (cmd.Site, "#B9");
Assert.IsNull (cmd.Transaction, "#B10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#B11");
cmd = new OleDbCommand (COMMAND_TEXT, (OleDbConnection) null);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#C1");
Assert.AreEqual (30, cmd.CommandTimeout, "#C2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#C3");
Assert.IsNull (cmd.Connection, "#C4");
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
Assert.IsNotNull (cmd.Parameters, "#C7");
Assert.AreEqual (0, cmd.Parameters.Count, "#C8");
Assert.IsNull (cmd.Site, "#C9");
Assert.IsNull (cmd.Transaction, "#C10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#C11");
}
[Test] // OleDbCommand (string, OleDbConnection, OleDbTransaction)
public void Constructor4 ()
{
OleDbConnection conn = new OleDbConnection ();
OleDbCommand cmd;
cmd = new OleDbCommand (COMMAND_TEXT, conn, (OleDbTransaction) null);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#A1");
Assert.AreEqual (30, cmd.CommandTimeout, "#A2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#A3");
Assert.AreSame (conn, cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNotNull (cmd.Parameters, "#A7");
Assert.AreEqual (0, cmd.Parameters.Count, "#A8");
Assert.IsNull (cmd.Site, "#A9");
Assert.IsNull (cmd.Transaction, "#A10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#A11");
cmd = new OleDbCommand ((string) null, conn, (OleDbTransaction) null);
Assert.AreEqual (string.Empty, cmd.CommandText, "#B1");
Assert.AreEqual (30, cmd.CommandTimeout, "#B2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#B3");
Assert.AreSame (conn, cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNotNull (cmd.Parameters, "#B7");
Assert.AreEqual (0, cmd.Parameters.Count, "#B8");
Assert.IsNull (cmd.Site, "#B9");
Assert.IsNull (cmd.Transaction, "#B10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#B11");
cmd = new OleDbCommand (COMMAND_TEXT, (OleDbConnection) null, (OleDbTransaction) null);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#C1");
Assert.AreEqual (30, cmd.CommandTimeout, "#C2");
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#C3");
Assert.IsNull (cmd.Connection, "#C4");
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
Assert.IsNotNull (cmd.Parameters, "#C7");
Assert.AreEqual (0, cmd.Parameters.Count, "#C8");
Assert.IsNull (cmd.Site, "#C9");
Assert.IsNull (cmd.Transaction, "#C10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#C11");
}
[Test]
public void CommandText ()
{
OleDbCommand cmd = new OleDbCommand ();
cmd.CommandText = COMMAND_TEXT;
Assert.AreSame (COMMAND_TEXT, cmd.CommandText, "#1");
cmd.CommandText = null;
Assert.AreEqual (string.Empty, cmd.CommandText, "#2");
cmd.CommandText = COMMAND_TEXT;
Assert.AreSame (COMMAND_TEXT, cmd.CommandText, "#3");
cmd.CommandText = string.Empty;
Assert.AreEqual (string.Empty, cmd.CommandText, "#4");
}
}
}
#endif

View File

@@ -1,234 +0,0 @@
//
// OleDbConnectionTest.cs - NUnit Test Cases for testing the
// OleDbConnectionTest class
// Author:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// Copyright (c) 2007 Gert Driesen
//
// 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.
//
#if !NO_OLEDB
using System;
using System.Data;
using System.Data.OleDb;
using NUnit.Framework;
namespace MonoTests.System.Data.OleDb
{
[TestFixture]
public class OleDbConnectionTest
{
const string CONNECTION_STRING = "Provider=sqloledb;Data Source=SQLSRV;Initial Catalog=Mono;";
[Test] // OleDbConnection ()
public void Constructor1 ()
{
OleDbConnection cn = new OleDbConnection ();
Assert.AreEqual (string.Empty, cn.ConnectionString, "#1");
Assert.AreEqual (15, cn.ConnectionTimeout, "#2");
Assert.IsNull (cn.Container, "#3");
Assert.AreEqual (string.Empty, cn.Database, "#4");
Assert.AreEqual (string.Empty, cn.DataSource, "#5");
Assert.AreEqual (string.Empty, cn.Provider, "#6");
Assert.IsNull (cn.Site, "#7");
Assert.AreEqual (ConnectionState.Closed, cn.State, "#8");
}
[Test] // OleDbConnection (string)
public void Constructor2 ()
{
OleDbConnection cn = new OleDbConnection (CONNECTION_STRING);
Assert.AreEqual (CONNECTION_STRING, cn.ConnectionString, "#A1");
Assert.AreEqual (15, cn.ConnectionTimeout, "#A2");
Assert.IsNull (cn.Container, "#A3");
//Assert.AreEqual ("Mono", cn.Database, "#A4");
//Assert.AreEqual ("SQLSRV", cn.DataSource, "#A5");
//Assert.AreEqual ("sqloledb", cn.Provider, "#A6");
Assert.IsNull (cn.Site, "#A7");
Assert.AreEqual (ConnectionState.Closed, cn.State, "#A8");
cn = new OleDbConnection ((string) null);
Assert.AreEqual (string.Empty, cn.ConnectionString, "#B1");
Assert.AreEqual (15, cn.ConnectionTimeout, "#B2");
Assert.IsNull (cn.Container, "#B3");
Assert.AreEqual (string.Empty, cn.Database, "#B4");
Assert.AreEqual (string.Empty, cn.DataSource, "#B5");
Assert.AreEqual (string.Empty, cn.Provider, "#B6");
Assert.IsNull (cn.Site, "#B7");
Assert.AreEqual (ConnectionState.Closed, cn.State, "#B8");
}
[Test]
public void BeginTransaction_Connection_Closed ()
{
OleDbConnection cn = new OleDbConnection ();
try {
cn.BeginTransaction ();
Assert.Fail ("#A1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
}
try {
cn.BeginTransaction ((IsolationLevel) 666);
Assert.Fail ("#B1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
try {
cn.BeginTransaction (IsolationLevel.Serializable);
Assert.Fail ("#C1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
Assert.IsNull (ex.InnerException, "#C3");
Assert.IsNotNull (ex.Message, "#C4");
}
}
[Test]
public void ConnectionString ()
{
OleDbConnection cn = new OleDbConnection ();
cn.ConnectionString = CONNECTION_STRING;
Assert.AreEqual (CONNECTION_STRING, cn.ConnectionString, "#1");
cn.ConnectionString = null;
Assert.AreEqual (string.Empty, cn.ConnectionString, "#2");
cn.ConnectionString = CONNECTION_STRING;
Assert.AreEqual (CONNECTION_STRING, cn.ConnectionString, "#3");
cn.ConnectionString = string.Empty;
Assert.AreEqual (string.Empty, cn.ConnectionString, "#4");
}
[Test]
public void GetSchema_Connection_Closed ()
{
OleDbConnection cn = new OleDbConnection ();
try {
cn.GetSchema ();
Assert.Fail ("#A1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
try {
cn.GetSchema ("Tables");
Assert.Fail ("#B1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
try {
cn.GetSchema ((string) null);
Assert.Fail ("#C1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
Assert.IsNull (ex.InnerException, "#C3");
Assert.IsNotNull (ex.Message, "#C4");
}
try {
cn.GetSchema ("Tables", new string [] { "master" });
Assert.Fail ("#D1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
Assert.IsNull (ex.InnerException, "#D3");
Assert.IsNotNull (ex.Message, "#D4");
}
try {
cn.GetSchema ((string) null, new string [] { "master" });
Assert.Fail ("#E1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
Assert.IsNull (ex.InnerException, "#E3");
Assert.IsNotNull (ex.Message, "#E4");
}
try {
cn.GetSchema ("Tables", (string []) null);
Assert.Fail ("#F1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
Assert.IsNull (ex.InnerException, "#F3");
Assert.IsNotNull (ex.Message, "#F4");
}
try {
cn.GetSchema ((string) null, (string []) null);
Assert.Fail ("#G1");
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#G2");
Assert.IsNull (ex.InnerException, "#G3");
Assert.IsNotNull (ex.Message, "#G4");
}
}
[Test]
public void ServerVersion_Connection_Closed ()
{
OleDbConnection cn = new OleDbConnection ();
try {
Assert.Fail ("#A1:" + cn.ServerVersion);
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
}
cn = new OleDbConnection (CONNECTION_STRING);
try {
Assert.Fail ("#B1:" + cn.ServerVersion);
} catch (InvalidOperationException ex) {
// Invalid operation. The connection is closed
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
}
}
}
#endif

View File

@@ -1,458 +0,0 @@
//
// OleDbDataAdapterTest.cs - NUnit Test Cases for testing the
// OleDbDataAdapter class
// Author:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// Copyright (c) 2007 Gert Driesen
//
// 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.
//
#if !NO_OLEDB
using System;
using System.Data;
#if !NO_ODBC
using System.Data.Odbc;
#endif
using System.Data.OleDb;
using NUnit.Framework;
namespace MonoTests.System.Data.OleDb
{
[TestFixture]
public class OleDbDataAdapterTest
{
[Test] // OleDbDataAdapter ()
public void Constructor1 ()
{
OleDbDataAdapter da = new OleDbDataAdapter ();
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNull (da.SelectCommand, "#11");
Assert.IsNull (da.Site, "#12");
Assert.IsNotNull (da.TableMappings, "#13");
Assert.AreEqual (0, da.TableMappings.Count, "#14");
Assert.AreEqual (1, da.UpdateBatchSize, "#15");
Assert.IsNull (da.UpdateCommand, "#16");
}
[Test] // OleDbDataAdapter (OleDbCommand)
public void Constructor2 ()
{
OleDbCommand cmd = new OleDbCommand ();
OleDbDataAdapter da = new OleDbDataAdapter (cmd);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNotNull (da.SelectCommand, "#11");
Assert.AreSame (cmd, da.SelectCommand, "#12");
Assert.IsNull (da.Site, "#13");
Assert.IsNotNull (da.TableMappings, "#14");
Assert.AreEqual (0, da.TableMappings.Count, "#15");
Assert.AreEqual (1, da.UpdateBatchSize, "#16");
Assert.IsNull (da.UpdateCommand, "#17");
}
[Test] // OleDbDataAdapter (OleDbCommand)
public void Constructor2_SelectCommand_Null ()
{
OleDbDataAdapter da = new OleDbDataAdapter ((OleDbCommand) null);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNull (da.SelectCommand, "#11");
Assert.IsNull (da.Site, "#12");
Assert.IsNotNull (da.TableMappings, "#13");
Assert.AreEqual (0, da.TableMappings.Count, "#14");
Assert.AreEqual (1, da.UpdateBatchSize, "#15");
Assert.IsNull (da.UpdateCommand, "#16");
}
[Test] // OleDbDataAdapter (string, OleDbCommand)
public void Constructor3 ()
{
string selectCommandText = "SELECT * FROM Authors";
OleDbConnection selectConnection = new OleDbConnection ();
OleDbDataAdapter da = new OleDbDataAdapter (selectCommandText,
selectConnection);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNotNull (da.SelectCommand, "#11");
Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
Assert.AreSame (selectConnection, da.SelectCommand.Connection, "#13");
Assert.IsNull (da.Site, "#14");
Assert.IsNotNull (da.TableMappings, "#15");
Assert.AreEqual (0, da.TableMappings.Count, "#16");
Assert.AreEqual (1, da.UpdateBatchSize, "#17");
Assert.IsNull (da.UpdateCommand, "#18");
}
[Test] // OleDbDataAdapter (string, OleDbConnection)
public void Constructor3_SelectCommandText_Null ()
{
OleDbConnection selectConnection = new OleDbConnection ();
OleDbDataAdapter da = new OleDbDataAdapter ((string) null,
selectConnection);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNotNull (da.SelectCommand, "#11");
Assert.IsNotNull (da.SelectCommand.CommandText, "#12");
Assert.AreEqual (string.Empty, da.SelectCommand.CommandText, "#13");
Assert.AreSame (selectConnection, da.SelectCommand.Connection, "#14");
Assert.IsNull (da.Site, "#15");
Assert.IsNotNull (da.TableMappings, "#16");
Assert.AreEqual (0, da.TableMappings.Count, "#17");
Assert.AreEqual (1, da.UpdateBatchSize, "#18");
Assert.IsNull (da.UpdateCommand, "#19");
}
[Test] // OleDbDataAdapter (string, OleDbConnection)
public void Constructor3_SelectConnection_Null ()
{
string selectCommandText = "SELECT * FROM Authors";
OleDbDataAdapter da = new OleDbDataAdapter (selectCommandText,
(OleDbConnection) null);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNotNull (da.SelectCommand, "#11");
Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
Assert.IsNull (da.SelectCommand.Connection, "#13");
Assert.IsNull (da.Site, "#14");
Assert.IsNotNull (da.TableMappings, "#15");
Assert.AreEqual (0, da.TableMappings.Count, "#16");
Assert.AreEqual (1, da.UpdateBatchSize, "#17");
Assert.IsNull (da.UpdateCommand, "#18");
}
[Test] // OleDbDataAdapter (string, string)]
public void Constructor4 ()
{
string selectCommandText = "SELECT * FROM Authors";
string selectConnectionString = "Provider=SQLOLEDB;Data Source=SQLSRV;";
OleDbDataAdapter da = new OleDbDataAdapter (selectCommandText,
selectConnectionString);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNotNull (da.SelectCommand, "#11");
Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
Assert.IsNotNull (da.SelectCommand.Connection, "#13");
Assert.AreEqual (selectConnectionString, da.SelectCommand.Connection.ConnectionString, "#14");
Assert.IsNull (da.Site, "#15");
Assert.IsNotNull (da.TableMappings, "#16");
Assert.AreEqual (0, da.TableMappings.Count, "#17");
Assert.AreEqual (1, da.UpdateBatchSize, "#18");
Assert.IsNull (da.UpdateCommand, "#19");
}
[Test] // OleDbDataAdapter (string, string)]
public void Constructor4_SelectCommandText_Null ()
{
string selectConnectionString = "Provider=SQLOLEDB;Data Source=SQLSRV;";
OleDbDataAdapter da = new OleDbDataAdapter ((string) null,
selectConnectionString);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNotNull (da.SelectCommand, "#11");
Assert.IsNotNull (da.SelectCommand.CommandText, "#12");
Assert.AreEqual (string.Empty, da.SelectCommand.CommandText, "#13");
Assert.IsNotNull (da.SelectCommand.Connection, "#14");
Assert.AreEqual (selectConnectionString, da.SelectCommand.Connection.ConnectionString, "#15");
Assert.IsNull (da.Site, "#16");
Assert.IsNotNull (da.TableMappings, "#17");
Assert.AreEqual (0, da.TableMappings.Count, "#18");
Assert.AreEqual (1, da.UpdateBatchSize, "#19");
Assert.IsNull (da.UpdateCommand, "#20");
}
[Test] // OleDbDataAdapter (string, string)]
public void Constructor4_SelectConnectionString_Null ()
{
string selectCommandText = "SELECT * FROM Authors";
OleDbDataAdapter da = new OleDbDataAdapter (selectCommandText,
(string) null);
Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
Assert.IsNull (da.Container, "#3");
Assert.IsFalse (da.ContinueUpdateOnError, "#4");
Assert.IsNull (da.DeleteCommand, "#5");
Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
Assert.IsNull (da.InsertCommand, "#7");
Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
Assert.IsNotNull (da.SelectCommand, "#11");
Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
Assert.IsNotNull (da.SelectCommand.Connection, "#14");
Assert.AreEqual (string.Empty, da.SelectCommand.Connection.ConnectionString, "#15");
Assert.IsNull (da.Site, "#16");
Assert.IsNotNull (da.TableMappings, "#17");
Assert.AreEqual (0, da.TableMappings.Count, "#18");
Assert.AreEqual (1, da.UpdateBatchSize, "#19");
Assert.IsNull (da.UpdateCommand, "#20");
}
[Test]
public void DeleteCommand ()
{
OleDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.DeleteCommand = cmd1;
Assert.AreSame (cmd1, da.DeleteCommand, "#1");
da.DeleteCommand = cmd2;
Assert.AreSame (cmd2, da.DeleteCommand, "#2");
da.DeleteCommand = null;
Assert.IsNull (da.DeleteCommand, "#3");
}
[Test]
public void DeleteCommand_IDbDataAdapter ()
{
IDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.DeleteCommand = cmd1;
Assert.AreSame (cmd1, da.DeleteCommand, "#A1");
da.DeleteCommand = cmd2;
Assert.AreSame (cmd2, da.DeleteCommand, "#A2");
da.DeleteCommand = null;
Assert.IsNull (da.DeleteCommand, "#A3");
try {
da.DeleteCommand = new OdbcCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
}
[Test]
public void Dispose ()
{
OleDbDataAdapter da = new OleDbDataAdapter ();
da.DeleteCommand = new OleDbCommand ();
da.InsertCommand = new OleDbCommand ();
da.SelectCommand = new OleDbCommand ();
da.UpdateCommand = new OleDbCommand ();
da.Dispose ();
Assert.IsNull (da.DeleteCommand, "#1");
Assert.IsNull (da.InsertCommand, "#2");
Assert.IsNull (da.SelectCommand, "#3");
Assert.IsNotNull (da.TableMappings, "#4");
Assert.AreEqual (0, da.TableMappings.Count, "#5");
Assert.IsNull (da.UpdateCommand, "#6");
}
[Test]
public void InsertCommand ()
{
OleDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.InsertCommand = cmd1;
Assert.AreSame (cmd1, da.InsertCommand, "#1");
da.InsertCommand = cmd2;
Assert.AreSame (cmd2, da.InsertCommand, "#2");
da.InsertCommand = null;
Assert.IsNull (da.InsertCommand, "#3");
}
[Test]
public void InsertCommand_IDbDataAdapter ()
{
IDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.InsertCommand = cmd1;
Assert.AreSame (cmd1, da.InsertCommand, "#A1");
da.InsertCommand = cmd2;
Assert.AreSame (cmd2, da.InsertCommand, "#A2");
da.InsertCommand = null;
Assert.IsNull (da.InsertCommand, "#A3");
try {
da.InsertCommand = new OdbcCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
}
[Test]
public void SelectCommand ()
{
OleDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.SelectCommand = cmd1;
Assert.AreSame (cmd1, da.SelectCommand, "#1");
da.SelectCommand = cmd2;
Assert.AreSame (cmd2, da.SelectCommand, "#2");
da.SelectCommand = null;
Assert.IsNull (da.SelectCommand, "#3");
}
[Test]
public void SelectCommand_IDbDataAdapter ()
{
IDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.SelectCommand = cmd1;
Assert.AreSame (cmd1, da.SelectCommand, "#A1");
da.SelectCommand = cmd2;
Assert.AreSame (cmd2, da.SelectCommand, "#A2");
da.SelectCommand = null;
Assert.IsNull (da.SelectCommand, "#A3");
try {
da.SelectCommand = new OdbcCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
}
[Test]
public void UpdateCommand ()
{
OleDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.UpdateCommand = cmd1;
Assert.AreSame (cmd1, da.UpdateCommand, "#1");
da.UpdateCommand = cmd2;
Assert.AreSame (cmd2, da.UpdateCommand, "#2");
da.UpdateCommand = null;
Assert.IsNull (da.UpdateCommand, "#3");
}
[Test]
public void UpdateCommand_IDbDataAdapter ()
{
IDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand cmd1 = new OleDbCommand ();
OleDbCommand cmd2 = new OleDbCommand ();
da.UpdateCommand = cmd1;
Assert.AreSame (cmd1, da.UpdateCommand, "#A1");
da.UpdateCommand = cmd2;
Assert.AreSame (cmd2, da.UpdateCommand, "#A2");
da.UpdateCommand = null;
Assert.IsNull (da.UpdateCommand, "#A3");
try {
da.UpdateCommand = new OdbcCommand ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
}
}
}
#endif

View File

@@ -1,55 +0,0 @@
//
// OleDbMetaDataCollectionNamesTest.cs - NUnit Test Cases for testing the
// OleDbMetaDataCollectionNames class
// Author:
// Ankit Jain <jankit@novell.com>
//
// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
//
// 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.
//
#if !NO_OLEDB
using System.Data.OleDb;
using NUnit.Framework;
namespace MonoTests.System.Data.OleDb
{
[TestFixture]
public class OleDbMetaDataCollectionNamesTest
{
[Test]
public void ValuesTest ()
{
Assert.AreEqual (OleDbMetaDataCollectionNames.Catalogs, "Catalogs");
Assert.AreEqual (OleDbMetaDataCollectionNames.Collations, "Collations");
Assert.AreEqual (OleDbMetaDataCollectionNames.Columns, "Columns");
Assert.AreEqual (OleDbMetaDataCollectionNames.Indexes, "Indexes");
Assert.AreEqual (OleDbMetaDataCollectionNames.ProcedureColumns, "ProcedureColumns");
Assert.AreEqual (OleDbMetaDataCollectionNames.ProcedureParameters, "ProcedureParameters");
Assert.AreEqual (OleDbMetaDataCollectionNames.Procedures, "Procedures");
Assert.AreEqual (OleDbMetaDataCollectionNames.Tables, "Tables");
Assert.AreEqual (OleDbMetaDataCollectionNames.Views, "Views");
}
}
}
#endif

View File

@@ -1,61 +0,0 @@
//
// OleDbParameterCollectionTest.cs -
// NUnit Test Cases for OleDbParameterCollection
//
// Author:
// Frederik Carlier <frederik.carlier@ugent.be>
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// 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.
//
#if !NO_OLEDB
using NUnit.Framework;
using System;
using System.Data;
using System.Data.OleDb;
namespace MonoTests.System.Data.OleDb {
[TestFixture]
public class OleDbParameterCollectionTest {
[Test]
[Category ("NotWorking")] // it tries to PInvoke LocalAlloc() and fails on non-Windows.
public void AddWithValueTest ()
{
OleDbCommand command = new OleDbCommand();
OleDbParameterCollection parameters = command.Parameters;
// Test with string
OleDbParameter parameter = parameters.AddWithValue("parameterName", "parameterValue");
Assert.AreEqual("parameterValue", parameter.Value);
Assert.AreEqual("parameterName", parameter.ParameterName);
Assert.AreEqual(DbType.AnsiString, parameter.DbType);
Assert.AreEqual(OleDbType.VarChar, parameter.OleDbType);
Assert.AreEqual(1, parameters.Count);
Assert.AreEqual(parameter, parameters[0]);
}
}
}
#endif

View File

@@ -1,201 +0,0 @@
//
// OleDbPermissionAttributeTest.cs -
// NUnit Test Cases for OleDbPermissionAttribute
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// 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.
//
#if !NO_OLEDB
using NUnit.Framework;
using System;
using System.Data;
using System.Data.OleDb;
using System.Security;
using System.Security.Permissions;
namespace MonoTests.System.Data.OleDb {
[TestFixture]
public class OleDbPermissionAttributeTest {
[Test]
public void Default ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId");
Assert.IsFalse (a.Unrestricted, "Unrestricted");
Assert.IsFalse (a.AllowBlankPassword, "AllowBlankPassword");
Assert.AreEqual (String.Empty, a.ConnectionString, "ConnectionString");
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
Assert.AreEqual (String.Empty, a.KeyRestrictions, "KeyRestrictions");
Assert.AreEqual (String.Empty, a.Provider, "Provider");
Assert.IsFalse (a.ShouldSerializeConnectionString (), "ShouldSerializeConnectionString");
Assert.IsFalse (a.ShouldSerializeKeyRestrictions (), "ShouldSerializeConnectionString");
OleDbPermission odp = (OleDbPermission)a.CreatePermission ();
Assert.IsFalse (odp.IsUnrestricted (), "IsUnrestricted");
}
[Test]
public void Action ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
Assert.AreEqual (SecurityAction.Assert, a.Action, "Action=Assert");
a.Action = SecurityAction.Demand;
Assert.AreEqual (SecurityAction.Demand, a.Action, "Action=Demand");
a.Action = SecurityAction.Deny;
Assert.AreEqual (SecurityAction.Deny, a.Action, "Action=Deny");
a.Action = SecurityAction.InheritanceDemand;
Assert.AreEqual (SecurityAction.InheritanceDemand, a.Action, "Action=InheritanceDemand");
a.Action = SecurityAction.LinkDemand;
Assert.AreEqual (SecurityAction.LinkDemand, a.Action, "Action=LinkDemand");
a.Action = SecurityAction.PermitOnly;
Assert.AreEqual (SecurityAction.PermitOnly, a.Action, "Action=PermitOnly");
a.Action = SecurityAction.RequestMinimum;
Assert.AreEqual (SecurityAction.RequestMinimum, a.Action, "Action=RequestMinimum");
a.Action = SecurityAction.RequestOptional;
Assert.AreEqual (SecurityAction.RequestOptional, a.Action, "Action=RequestOptional");
a.Action = SecurityAction.RequestRefuse;
Assert.AreEqual (SecurityAction.RequestRefuse, a.Action, "Action=RequestRefuse");
}
[Test]
public void Action_Invalid ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute ((SecurityAction)Int32.MinValue);
// no validation in attribute
}
[Test]
public void Unrestricted ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
a.Unrestricted = true;
OleDbPermission odp = (OleDbPermission)a.CreatePermission ();
Assert.IsTrue (odp.IsUnrestricted (), "IsUnrestricted");
Assert.IsFalse (a.AllowBlankPassword, "AllowBlankPassword");
Assert.AreEqual (String.Empty, a.ConnectionString, "ConnectionString");
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
Assert.AreEqual (String.Empty, a.KeyRestrictions, "KeyRestrictions");
a.Unrestricted = false;
odp = (OleDbPermission)a.CreatePermission ();
Assert.IsFalse (odp.IsUnrestricted (), "!IsUnrestricted");
}
[Test]
public void AllowBlankPassword ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
Assert.IsFalse (a.AllowBlankPassword, "Default");
a.AllowBlankPassword = true;
Assert.IsTrue (a.AllowBlankPassword, "True");
a.AllowBlankPassword = false;
Assert.IsFalse (a.AllowBlankPassword, "False");
}
[Test]
public void ConnectionString ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
a.ConnectionString = String.Empty;
Assert.AreEqual (String.Empty, a.ConnectionString, "Empty");
a.ConnectionString = "Mono";
Assert.AreEqual ("Mono", a.ConnectionString, "Mono");
a.ConnectionString = null;
Assert.AreEqual (String.Empty, a.ConnectionString, "Empty(null)");
}
[Test]
public void KeyRestrictionBehavior_All ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
a.KeyRestrictionBehavior = KeyRestrictionBehavior.AllowOnly;
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "AllowOnly");
a.KeyRestrictionBehavior = KeyRestrictionBehavior.PreventUsage;
Assert.AreEqual (KeyRestrictionBehavior.PreventUsage, a.KeyRestrictionBehavior, "PreventUsage");
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void KeyRestrictionBehavior_Invalid ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
a.KeyRestrictionBehavior = (KeyRestrictionBehavior)Int32.MinValue;
}
[Test]
public void KeyRestriction ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
a.KeyRestrictions = String.Empty;
Assert.AreEqual (String.Empty, a.KeyRestrictions, "Empty");
a.KeyRestrictions = "Mono";
Assert.AreEqual ("Mono", a.KeyRestrictions, "Mono");
a.KeyRestrictions = null;
Assert.AreEqual (String.Empty, a.KeyRestrictions, "Empty(null)");
}
[Test]
public void Provider ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
a.Provider = String.Empty;
Assert.AreEqual (String.Empty, a.Provider, "Empty");
a.Provider = "Mono";
Assert.AreEqual ("Mono", a.Provider, "Mono");
a.Provider = null;
Assert.AreEqual (String.Empty, a.Provider, "Empty(null)");
}
[Test]
public void CreatePermission_Provider ()
{
OleDbPermissionAttribute a = new OleDbPermissionAttribute (SecurityAction.Assert);
a.Provider = "Mono";
Assert.AreEqual ("Mono", a.Provider, "Mono");
OleDbPermission odp = (OleDbPermission) a.CreatePermission ();
// provider isn't even supplied to permission in fx 2.0
Assert.AreEqual (String.Empty, odp.Provider, "CreatePermission.Provider");
}
[Test]
public void Attributes ()
{
Type t = typeof (OleDbPermissionAttribute);
Assert.IsTrue (t.IsSerializable, "IsSerializable");
object [] attrs = t.GetCustomAttributes (typeof (AttributeUsageAttribute), false);
Assert.AreEqual (1, attrs.Length, "AttributeUsage");
AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];
Assert.IsTrue (aua.AllowMultiple, "AllowMultiple");
Assert.IsFalse (aua.Inherited, "Inherited");
AttributeTargets at = AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method;
Assert.AreEqual (at, aua.ValidOn, "ValidOn");
}
}
}
#endif

View File

@@ -1,135 +0,0 @@
//
// OleDbPermissionTest.cs - NUnit Test Cases for OleDbPermission
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// 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.
//
#if !NO_OLEDB
using NUnit.Framework;
using System;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Security;
using System.Security.Permissions;
namespace MonoTests.System.Data.OleDb {
// NOTE: Most tests are are located in the base class, DBDataPermission
[TestFixture]
public class OleDbPermissionTest {
private void Check (string msg, OleDbPermission perm, bool blank, bool unrestricted, int count)
{
Assert.AreEqual (blank, perm.AllowBlankPassword, msg + ".AllowBlankPassword");
Assert.AreEqual (unrestricted, perm.IsUnrestricted (), msg + ".IsUnrestricted");
if (count == 0)
Assert.IsNull (perm.ToXml ().Children, msg + ".Count != 0");
else
Assert.AreEqual (count, perm.ToXml ().Children.Count, msg + ".Count");
Assert.AreEqual (String.Empty, perm.Provider, "Provider");
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void PermissionState_Invalid ()
{
PermissionState ps = (PermissionState)Int32.MinValue;
OleDbPermission perm = new OleDbPermission (ps);
}
[Test]
public void None ()
{
OleDbPermission perm = new OleDbPermission (PermissionState.None);
Check ("None-1", perm, false, false, 0);
perm.AllowBlankPassword = true;
Check ("None-2", perm, true, false, 0);
OleDbPermission copy = (OleDbPermission)perm.Copy ();
Check ("Copy_None-1", copy, true, false, 0);
copy.AllowBlankPassword = false;
Check ("Copy_None-2", copy, false, false, 0);
}
[Test]
public void None_Childs ()
{
OleDbPermission perm = new OleDbPermission (PermissionState.None);
perm.Add ("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly);
perm.Add ("data source=127.0.0.1;", "password=;", KeyRestrictionBehavior.PreventUsage);
Check ("None-Childs-1", perm, false, false, 2);
perm.AllowBlankPassword = true;
Check ("None-Childs-2", perm, true, false, 2);
OleDbPermission copy = (OleDbPermission)perm.Copy ();
Check ("Copy_None-Childs-1", copy, true, false, 2);
copy.AllowBlankPassword = false;
Check ("Copy_None-Childs-2", copy, false, false, 2);
}
[Test]
public void Unrestricted ()
{
OleDbPermission perm = new OleDbPermission (PermissionState.Unrestricted);
Check ("Unrestricted-1", perm, false, true, 0);
perm.AllowBlankPassword = true;
Check ("Unrestricted-2", perm, true, true, 0);
OleDbPermission copy = (OleDbPermission)perm.Copy ();
// note: Unrestricted is always created with default values (so AllowBlankPassword is false)
Check ("Copy_Unrestricted-1", copy, false, true, 0);
copy.AllowBlankPassword = true;
Check ("Copy_Unrestricted-2", copy, true, true, 0);
}
[Test]
public void Unrestricted_Add ()
{
OleDbPermission perm = new OleDbPermission (PermissionState.Unrestricted);
Check ("Unrestricted-NoChild", perm, false, true, 0);
perm.Add ("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly);
// note: Lost unrestricted state when children was added
Check ("Unrestricted-WithChild", perm, false, false, 1);
}
[Test]
public void Provider ()
{
OleDbPermission perm = new OleDbPermission (PermissionState.None);
perm.Provider = String.Empty;
Assert.AreEqual (String.Empty, perm.Provider, "Empty");
perm.Provider = "Mono";
Assert.AreEqual ("Mono", perm.Provider, "Mono");
perm.Provider = null;
Assert.AreEqual (String.Empty, perm.Provider, "Empty(null)");
}
}
}
#endif

View File

@@ -94,7 +94,7 @@ namespace MonoTests.System.Data.Sql
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.AreEqual ("Service", ex.ParamName, "#5");
Assert.AreEqual ("Options", ex.ParamName, "#5");
}
}
@@ -156,7 +156,7 @@ namespace MonoTests.System.Data.Sql
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.AreEqual ("Service", ex.ParamName, "#5");
Assert.AreEqual ("Options", ex.ParamName, "#5");
}
}

View File

@@ -55,7 +55,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#5");
Assert.IsTrue (cmd.DesignTimeVisible, "#6");
Assert.IsNull (cmd.Notification, "#7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#8");
// Not implemented in corefx:
//Assert.IsTrue (cmd.NotificationAutoEnlist, "#8");
Assert.IsNotNull (cmd.Parameters, "#9");
Assert.AreEqual (0, cmd.Parameters.Count, "#10");
Assert.IsNull (cmd.Site, "#11");
@@ -77,7 +78,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNull (cmd.Notification, "#A7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
// Not implemented in corefx:
// Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
Assert.IsNotNull (cmd.Parameters, "#A9");
Assert.AreEqual (0, cmd.Parameters.Count, "#A10");
Assert.IsNull (cmd.Site, "#A11");
@@ -92,7 +94,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNull (cmd.Notification, "#B7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
// Not implemented in corefx:
// Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
Assert.IsNotNull (cmd.Parameters, "#B9");
Assert.AreEqual (0, cmd.Parameters.Count, "#B10");
Assert.IsNull (cmd.Site, "#B11");
@@ -117,7 +120,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNull (cmd.Notification, "#A7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
// Not implemented in corefx:
// Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
Assert.IsNotNull (cmd.Parameters, "#A9");
Assert.AreEqual (0, cmd.Parameters.Count, "#A10");
Assert.IsNull (cmd.Site, "#A11");
@@ -132,7 +136,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNull (cmd.Notification, "#B7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
// Not implemented in corefx:
//Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
Assert.IsNotNull (cmd.Parameters, "#B9");
Assert.AreEqual (0, cmd.Parameters.Count, "#B10");
Assert.IsNull (cmd.Site, "#B11");
@@ -147,7 +152,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
Assert.IsNull (cmd.Notification, "#C7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#C8");
// Not implemented in corefx:
//Assert.IsTrue (cmd.NotificationAutoEnlist, "#C8");
Assert.IsNotNull (cmd.Parameters, "#C9");
Assert.AreEqual (0, cmd.Parameters.Count, "#C10");
Assert.IsNull (cmd.Site, "#C11");
@@ -172,7 +178,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNull (cmd.Notification, "#A7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
// Not implemented in corefx:
// Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
Assert.IsNotNull (cmd.Parameters, "#A9");
Assert.AreEqual (0, cmd.Parameters.Count, "#A10");
Assert.IsNull (cmd.Site, "#A11");
@@ -187,7 +194,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNull (cmd.Notification, "#B7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
// Not implemented in corefx:
// Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
Assert.IsNotNull (cmd.Parameters, "#B9");
Assert.AreEqual (0, cmd.Parameters.Count, "#B10");
Assert.IsNull (cmd.Site, "#B11");
@@ -202,7 +210,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
Assert.IsNull (cmd.Notification, "#C7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#C8");
// Not implemented in corefx:
// Assert.IsTrue (cmd.NotificationAutoEnlist, "#C8");
Assert.IsNotNull (cmd.Parameters, "#C9");
Assert.AreEqual (0, cmd.Parameters.Count, "#C10");
Assert.IsNull (cmd.Site, "#C11");
@@ -224,7 +233,8 @@ namespace MonoTests.System.Data.SqlClient
cmd.CommandType = CommandType.StoredProcedure;
cmd.DesignTimeVisible = false;
cmd.Notification = notificationReq;
cmd.NotificationAutoEnlist = false;
// not implemented in corefx
//cmd.NotificationAutoEnlist = false;
cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
cmd.Parameters ["@TestPar1"].Value = DBNull.Value;
cmd.Parameters.AddWithValue ("@BirthDate", DateTime.Now);
@@ -237,7 +247,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Connection, "#4");
Assert.IsFalse (cmd.DesignTimeVisible, "#5");
Assert.AreSame (notificationReq, cmd.Notification, "#6");
Assert.IsFalse (cmd.NotificationAutoEnlist, "#7");
// not implemented in corefx
//Assert.IsFalse (cmd.NotificationAutoEnlist, "#7");
Assert.AreEqual (2, clone.Parameters.Count, "#8");
Assert.AreEqual (100, clone.CommandTimeout, "#9");
clone.Parameters.AddWithValue ("@test", DateTime.Now);
@@ -480,50 +491,13 @@ namespace MonoTests.System.Data.SqlClient
{
SqlCommand cmd;
// Text, without parameters
cmd = new SqlCommand ("select count(*) from whatever");
try {
cmd.Prepare ();
Assert.Fail ("#A1");
} catch (NullReferenceException) {
}
// Text, with parameters
cmd = new SqlCommand ("select count(*) from whatever");
cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
try {
cmd.Prepare ();
Assert.Fail ("#B1");
} catch (NullReferenceException) {
}
// Text, without parameters
cmd = new SqlCommand ("select count(*) from whatever");
cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
cmd.Parameters.Clear ();
try {
cmd.Prepare ();
Assert.Fail ("#C1");
} catch (NullReferenceException) {
}
// StoredProcedure, without parameters
cmd = new SqlCommand ("FindCustomer");
cmd.CommandType = CommandType.StoredProcedure;
try {
cmd.Prepare ();
Assert.Fail ("#D1");
} catch (NullReferenceException) {
}
// StoredProcedure, with parameters
cmd = new SqlCommand ("FindCustomer");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
try {
cmd.Prepare ();
Assert.Fail ("#E1");
} catch (NullReferenceException) {
} catch (InvalidOperationException) {
}
}

View File

@@ -64,6 +64,7 @@ namespace MonoTests.System.Data.Common
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void PropertiesTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;");
@@ -75,6 +76,7 @@ namespace MonoTests.System.Data.Common
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void ItemTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;");
@@ -102,6 +104,7 @@ namespace MonoTests.System.Data.Common
}
[Test, ExpectedException (typeof (ArgumentException))]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void InvalidKeyTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;Network=DBMSSOCN");
@@ -110,6 +113,7 @@ namespace MonoTests.System.Data.Common
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
public void RemoveTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER = localhost ;Network=DBMSSOCN");

View File

@@ -56,7 +56,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cn.Site, "#8");
Assert.AreEqual (ConnectionState.Closed, cn.State, "#9");
Assert.IsFalse (cn.StatisticsEnabled, "#10");
Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#11");
// https://github.com/dotnet/corefx/issues/22871
//Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#11");
}
[Test] // SqlConnection (string)
@@ -78,7 +79,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cn.Site, "#A8");
Assert.AreEqual (ConnectionState.Closed, cn.State, "#A9");
Assert.IsFalse (cn.StatisticsEnabled, "#A10");
Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#A11");
// https://github.com/dotnet/corefx/issues/22871
//Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#A11");
cn = new SqlConnection ((string) null);
Assert.AreEqual (string.Empty, cn.ConnectionString, "#B1");
@@ -91,7 +93,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cn.Site, "#B8");
Assert.AreEqual (ConnectionState.Closed, cn.State, "#B9");
Assert.IsFalse (cn.StatisticsEnabled, "#B10");
Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#B11");
// https://github.com/dotnet/corefx/issues/22871
//Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#B11");
}
[Test]
@@ -279,6 +282,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -297,6 +301,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -333,6 +338,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -355,6 +361,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -457,7 +464,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Container, "#6");
Assert.IsTrue (cmd.DesignTimeVisible, "#7");
Assert.IsNull (cmd.Notification, "#8");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#9");
// not implemented in corefx yet
// Assert.IsTrue (cmd.NotificationAutoEnlist, "#9");
Assert.IsNotNull (cmd.Parameters, "#10");
Assert.AreEqual (0, cmd.Parameters.Count, "#11");
Assert.IsNull (cmd.Site, "#12");
@@ -479,7 +487,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreEqual (string.Empty, cn.Database, "#3");
Assert.AreEqual (string.Empty, cn.DataSource, "#4");
Assert.AreEqual (8000, cn.PacketSize, "#5");
Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#6");
// https://github.com/dotnet/corefx/issues/22871
// Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#6");
Assert.AreEqual (ConnectionState.Closed, cn.State, "#7");
cn.Dispose ();
@@ -488,6 +497,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] //https://github.com/dotnet/corefx/issues/22882
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -567,6 +577,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -578,6 +589,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22879
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -904,6 +916,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -916,6 +929,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22879
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
@@ -1055,6 +1069,7 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
[Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif

View File

@@ -41,6 +41,9 @@ namespace MonoTests.System.Data.SqlClient
public class SqlDataAdapterTest
{
[Test] // SqlDataAdapter ()
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor1 ()
{
SqlDataAdapter da = new SqlDataAdapter ();
@@ -90,6 +93,9 @@ namespace MonoTests.System.Data.SqlClient
}
[Test] // SqlDataAdapter (SqlCommand)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor2_SelectCommand_Null ()
{
SqlDataAdapter da = new SqlDataAdapter ((SqlCommand) null);
@@ -374,6 +380,9 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void UpdateBatchSize ()
{
SqlDataAdapter da = new SqlDataAdapter ();
@@ -386,6 +395,9 @@ namespace MonoTests.System.Data.SqlClient
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void UpdateBatchSize_Negative ()
{
SqlDataAdapter da = new SqlDataAdapter ();