Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,9 @@
2006-10-19 Leszek Ciesielski <skolima@gmail.com>
* OracleConnection_InfoMessage.cs:
* OracleParameter_ctor_SOtype.cs: Removed attribute NotWorking
2006-10-17 Leszek Ciesielski <skolima@gmail.com>
* OracleConnection_InfoMessage.cs:
* OracleParameter_ctor_SOtype.cs: Set attribute NotWorking

View File

@ -0,0 +1,144 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient ;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
class IDBConnection_For_Oracle : GHTBase
{
string _ConnectionString = "";
[SetUp]
public void SetUp()
{
try
{
_ConnectionString = MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString;
}
catch(Exception ex)
{
EndCase(ex);
}
}
[TearDown]
public void TearDown()
{
}
public static void Main()
{
IDBConnection_For_Oracle tc = new IDBConnection_For_Oracle();
Exception exp = null;
try
{
tc.BeginTest("IDBConnection_For_Oracle");
tc.SetUp();
tc.run();
tc.TearDown();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
IDbConnection ICon = new OracleConnection();
try
{
BeginCase("check IDbConnection is null");
Compare(ICon != null, true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection type");
Compare(ICon.GetType().FullName ,typeof(OracleConnection).FullName);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
ICon = new OracleConnection(_ConnectionString);
try
{
BeginCase("check IDbConnection connection string");
Compare(ICon.ConnectionString ,_ConnectionString);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection ConnectionTimeout");
Compare(ICon.ConnectionTimeout ,15);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection state - closed");
Compare(ICon.State ,ConnectionState.Closed);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
ICon.Open();
try
{
BeginCase("check IDbConnection - open");
Compare(ICon.State ,ConnectionState.Open );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection CreateCommand");
IDbCommand cmd = ICon.CreateCommand();
Compare(cmd.GetType().FullName ,typeof(OracleCommand).FullName);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (ICon.State == ConnectionState.Open) ICon.Close();
}
}
}

View File

@ -0,0 +1,162 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient ;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_BeginTransaction : ADONetTesterClass
{
Exception exp = null;
OracleConnection con = null;
OracleTransaction tran = null;
public static void Main()
{
OracleConnection_BeginTransaction tc = new OracleConnection_BeginTransaction();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_BeginTransaction");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[SetUp]
public void SetUp() {
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
}
[TearDown]
public void TearDown() {
if (con != null && con.State == ConnectionState.Open) con.Close();
}
[Test]
#if JAVA
[Category("NotWorking")]
#endif
public void TestBeginTransactionChaos() {
DataBaseServer dbType = ConnectedDataProvider.GetDbType(con);
// not supported on DB2 and Oracle and Sybase
if (dbType != DataBaseServer.Oracle && dbType != DataBaseServer.DB2 && dbType != DataBaseServer.Sybase) {
con.Close();
con.Open();
try {
BeginCase("BeginTransaction - IsolationLevel Chaos");
tran = con.BeginTransaction(IsolationLevel.Chaos);
Compare(tran == null, false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
/* not supported by MSSQL,DB2,Oracle
con.Close();
con.Open();
try
{
BeginCase("BeginTransaction - IsolationLevel Unspecified");
tran = con.BeginTransaction(IsolationLevel.Unspecified );
Compare(tran == null, false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
*/
}
[Test]
public void run()
{
try
{
BeginCase("BeginTransaction");
tran = con.BeginTransaction();
Compare(tran == null, false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
con.Close();
con.Open();
try
{
BeginCase("BeginTransaction - IsolationLevel ReadCommitted");
tran = con.BeginTransaction(IsolationLevel.ReadCommitted);
Compare(tran == null, false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
DataBaseServer dbType = ConnectedDataProvider.GetDbType(con);
//Not supported by JDBC driver for oracle
if (dbType != DataBaseServer.Oracle)
{
con.Close();
con.Open();
try
{
BeginCase("BeginTransaction - IsolationLevel ReadUncommitted");
tran = con.BeginTransaction(IsolationLevel.ReadUncommitted );
Compare(tran == null, false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
con.Close();
con.Open();
try
{
BeginCase("BeginTransaction - IsolationLevel RepeatableRead");
tran = con.BeginTransaction(IsolationLevel.RepeatableRead);
Compare(tran == null, false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
con.Close();
con.Open();
try
{
BeginCase("BeginTransaction - IsolationLevel Serializable");
tran = con.BeginTransaction(IsolationLevel.Serializable );
Compare(tran == null, false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
}
}
}

View File

@ -0,0 +1,103 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient ;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_ChangeDatabase : ADONetTesterClass
{
public static void Main()
{
OracleConnection_ChangeDatabase tc = new OracleConnection_ChangeDatabase();
Exception exp = null;
try
{
tc.BeginTest("NoName");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
[Category("NotWorking")]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
//Currently not running on Oracle/DB2: .Net-Failed, GH:Pass
//not runnig on postgres because "The 'current catalog' property is not supported by the 'Mainsoft.JDBC.OLEDB.1' provider."
if (ConnectedDataProvider.GetDbType(con) != DataBaseServer.Oracle &&
ConnectedDataProvider.GetDbType(con) != DataBaseServer.DB2 &&
ConnectedDataProvider.GetDbType(con) != DataBaseServer.Sybase &&
ConnectedDataProvider.GetDbType(con) != DataBaseServer.PostgreSQL)
{
try
{
BeginCase("Change DataBase");
((IDbConnection)con).ChangeDatabase("GHTDB_EX");
Compare(((IDbConnection)con).Database , "GHTDB_EX");
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("Check DataBase Changed ");
OracleCommand cmd = new OracleCommand("select count(*) from Customers", con);
object obj = cmd.ExecuteScalar();
Compare(obj != null, true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,111 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient ;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_Close : GHTBase
{
[SetUp]
public void SetUp()
{
Exception exp = null;
BeginCase("Setup");
try
{
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
[TearDown]
public void TearDown()
{
}
public static void Main()
{
OracleConnection_Close tc = new OracleConnection_Close();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_Close");
tc.SetUp();
tc.run();
tc.TearDown();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
try
{
BeginCase("Close without open");
con.Close();
Compare(con.State , ConnectionState.Closed);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
con.Open();
try
{
BeginCase("Close after open");
con.Close();
Compare(con.State , ConnectionState.Closed);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
//An application can call Close more than one time.
//No exception is generated.
try
{
BeginCase("Close again");
con.Close();
Compare(con.State , ConnectionState.Closed);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
}
}

View File

@ -0,0 +1,243 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.Text;
using System.Data;
using System.Data.OracleClient ;
using System.Collections;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_ConnectionString : GHTBase
{
private Exception exp = null;
private OracleConnection con = new OracleConnection();
public static void Main()
{
OracleConnection_ConnectionString tc = new OracleConnection_ConnectionString();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_ConnectionString");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
public void run()
{
SetConnectionString();
ConstractorWithConnectionString();
DB2MissingProperties();
TestCaseForBug3925();
}
#region Tests
[Test]
public void DB2MissingProperties()
{
if (ConnectedDataProvider.GetDbType() != DataBaseServer.DB2)
{
Log("The 'DB2MissingProperties' subtest did not ran because it is relevant only for runs on DB2." );
return;
}
string[] propsToUse;
string description;
//The complete list of properties is:
//Provider, Password, User ID, Data Source, HostName, Port, Location, retrieveMessagesFromServerOnGetMessage
description = "Test connection string without 'retrieveMessagesFromServerOnGetMessage'";
propsToUse = new string[] {"Provider", "Password", "User ID", "Data Source", "HostName", "Port", "Location"};
DoTestWithSpecificProperties(propsToUse, description);
description = "Test connection string without 'HostName'";
propsToUse = new string[] {"Provider", "Password", "User ID", "Data Source", "Port", "Location", "retrieveMessagesFromServerOnGetMessage"};
DoTestWithSpecificProperties(propsToUse, description);
description = "Test connection string without 'Port'";
propsToUse = new string[] {"Provider", "Password", "User ID", "Data Source", "HostName", "Location", "retrieveMessagesFromServerOnGetMessage"};
DoTestWithSpecificProperties(propsToUse, description);
description = "Test connection string without 'Location'";
propsToUse = new string[] {"Provider", "Password", "User ID", "Data Source", "HostName", "Port", "retrieveMessagesFromServerOnGetMessage"};
DoTestWithSpecificProperties(propsToUse, description);
description = "Test connection string without 'HostName' & 'Port'";
propsToUse = new string[] {"Provider", "Password", "User ID", "Data Source", "Location", "retrieveMessagesFromServerOnGetMessage"};
DoTestWithSpecificProperties(propsToUse, description);
}
void DoTestWithSpecificProperties(string[] propsToUse, string description)
{
try
{
BeginCase(description);
exp = null;
Hashtable connectionProps = GetConnectionStringProps(ConnectedDataProvider.ConnectionString);
string actualConString = CreateConStringWithProps(propsToUse, connectionProps);
con = new OracleConnection(actualConString);
con.Open();
Compare(con.State, ConnectionState.Open);
}
catch(Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp=null;
if (con != null && con.State == ConnectionState.Open)
{
con.Close();
}
}
}
[Test]
public void ConstractorWithConnectionString()
{
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
try
{
BeginCase("Constructor with ConnectionString");
Compare(con.ConnectionString, MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
}
catch(Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
[Test]
public void SetConnectionString()
{
con.ConnectionString = MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString;
try
{
BeginCase("Set ConnectionString");
Compare(con.ConnectionString, MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
}
catch(Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
[Test]
#if !JAVA
[Category ("NotWorking")]
#endif
public void TestCaseForBug3925()
{
exp=null;
try
{
BeginCase("Test Case for bug #3925");
if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer)
{
Skip("This test currently runs only on SQLServer in java.");
return;
}
Hashtable conProps = GetConnectionStringProps(ConnectedDataProvider.ConnectionString);
string server = (string)conProps["Data Source"];
string user = (string)conProps["User Id"];
string password = (string)conProps["Password"];
string database = (string)conProps["Initial Catalog"];
string jdbcUrlTemplate = "JdbcDriverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver;JdbcURL=\"jdbc:microsoft:sqlserver://{0};User={1};Password={2};DatabaseName={3}\"";
string conStr = string.Format(jdbcUrlTemplate, server, user, password, database);
con = new OracleConnection(conStr);
con.Open();
Compare(ConnectionState.Open, con.State);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
if (con != null && con.State != ConnectionState.Closed)
{
con.Close();
}
}
}
#endregion
#region Utilities
private string CreateConStringWithProps(string[] propsToUse, Hashtable connectionProps)
{
StringBuilder actualConStringBuilder = new StringBuilder();
foreach(string prop in propsToUse)
{
string propString = string.Format("{0}={1}", prop, connectionProps[prop]);
actualConStringBuilder.Append(propString);
actualConStringBuilder.Append(";");
}
return actualConStringBuilder.ToString();
}
private Hashtable GetConnectionStringProps(string connectionString)
{
string[] connectionStringProps = connectionString.Split(';');
Hashtable connectionProps = new Hashtable();
foreach(string prop in connectionStringProps)
{
string[] keyValue = prop.Split('=');
if (keyValue.Length == 2)
{
connectionProps.Add(keyValue[0], keyValue[1]);
}
else
{
connectionProps.Add(prop, prop);
}
}
return connectionProps;
}
#endregion
}
}

View File

@ -0,0 +1,88 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_ConnectionTimeout : GHTBase
{
public static void Main()
{
OracleConnection_ConnectionTimeout tc = new OracleConnection_ConnectionTimeout();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_ConnectionTimeout");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString + ";Connect timeout=44");
try
{
BeginCase("ConnectionTimeout from Connection string");
Compare(((IDbConnection)con).ConnectionTimeout , 44);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
try
{
BeginCase("ConnectionTimeout default");
Compare(((IDbConnection)con).ConnectionTimeout , 15);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,80 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_CreateCommand : GHTBase
{
public static void Main()
{
OracleConnection_CreateCommand tc = new OracleConnection_CreateCommand();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_CreateCommand");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection();
OracleCommand cmd = null;
try
{
BeginCase("CreateCommand");
cmd = con.CreateCommand();
Compare(cmd!=null, true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,93 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_DataSource : ADONetTesterClass
{
public static void Main()
{
OracleConnection_DataSource tc = new OracleConnection_DataSource();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_DataSource");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
//test does not apply to ORACLE,DB2,Postgres
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.Oracle) return;
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.DB2) return;
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.PostgreSQL) return;
//get the expected result from the connection string
string[] arrCon = con.ConnectionString.Split(';');
string result = null;
for (int i=0; i < arrCon.Length; i++)
if (arrCon[i].IndexOf("Data Source") >= 0)
{
result = arrCon[i];
break;
}
result = result.Substring(result.IndexOf('=')+1).Trim();
try
{
BeginCase("check DataSource");
Compare(con.DataSource , result);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,94 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_Database : ADONetTesterClass
{
public static void Main()
{
OracleConnection_Database tc = new OracleConnection_Database();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_Database");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
//test does not apply to ORACLE,DB2,Sybase,Postgres
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.Oracle) return;
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.DB2) return;
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.Sybase) return;
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.PostgreSQL) return;
//get the expected result from the connection string
string[] arrCon = con.ConnectionString.Split(';');
string result = null;
for (int i=0; i < arrCon.Length; i++)
if (arrCon[i].IndexOf("Initial Catalog") >= 0)
{
result = arrCon[i];
break;
}
result = result.Substring(result.IndexOf('=')+1).Trim();
try
{
BeginCase("check Database");
Compare(((IDbConnection)con).Database , result);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,103 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_Equals : GHTBase
{
public static void Main()
{
OracleConnection_Equals tc = new OracleConnection_Equals();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_Equals");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con1 ,con2,con3;
con1 = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString );
con3 = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString );
con2 = con1;
con1.Open ();
try
{
BeginCase("Equals 1");
Compare(con1.Equals(con2),true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("Equals 2");
Compare(Equals(con2,con1),true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("Equals 3");
Compare(con1.Equals(con3),false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
con1.Close();
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,167 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.Threading;
using System.Data;
using NUnit.Framework;
using MonoTests.System.Data.Utils;
using System.Data.OracleClient;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_InfoMessage : GHTBase
{
private int errorCounter=0;
public static void Main()
{
OracleConnection_InfoMessage tc = new OracleConnection_InfoMessage();
Exception exp = null;
try
{
// Every Test must begin with BeginTest
tc.BeginTest("OracleConnection_InfoMessage");
tc.run();
}
catch(Exception ex)
{
exp = ex;
}
finally
{
// Every Test must End with EndTest
tc.EndTest(exp);
}
}
public void run()
{
Exception exp = null;
// Start Sub Test
try
{
test();
}
catch(Exception ex)
{
exp = ex;
}
finally
{
// Every Sub Test must end with EndCase
EndCase(exp);
exp = null;
}
// End Sub Test
}
[Test]
#if JAVA
[Category("NotWorking")]
#endif
public void test()
{
BeginCase("InfoMessage testing");
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
con.InfoMessage+=new OracleInfoMessageEventHandler(con_InfoMessage);
generateError(con);
con.Close();
}
private void generateError(OracleConnection con)
{
string errorString = string.Empty;
OracleCommand cmd = new OracleCommand(string.Empty,con);
switch (ConnectedDataProvider.GetDbType(con))
{
case DataBaseServer.SQLServer:
case DataBaseServer.Sybase:
{
cmd.CommandText = "Raiserror ('A sample SQL informational message',10,1)";
break;
}
case DataBaseServer.Oracle:
case DataBaseServer.PostgreSQL:
{
cmd.CommandText = "GH_ERROR";
//cmd.CommandText = "print 'This is a warning.'";
//cmd.CommandText = "select count(SUPPLIERID) from GHTDB.PRODUCTS";
cmd.CommandType = CommandType.StoredProcedure;
break;
}
case DataBaseServer.DB2:
{
cmd.CommandText = "SIGNAL SQLSTATE '99999' SET MESSAGE_TEXT ='Blah Blah';";
break;
}
default:
{
throw new NotImplementedException(string.Format("GHT: Test is not implemented for {0}", ConnectedDataProvider.GetDbType(con)));
}
}
//cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
// cmd.CommandText = "TestInfoMessage";
// cmd.CommandType = CommandType.StoredProcedure;
if (errorCounter == 0)
{
Thread.Sleep(5000);
}
Compare(errorCounter,1);
}
private void con_InfoMessage(object sender, OracleInfoMessageEventArgs e)
{
errorCounter++;
}
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,96 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_New : GHTBase
{
public static void Main()
{
OracleConnection_New tc = new OracleConnection_New();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_New");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = null;
try
{
BeginCase("OracleConnection ctor");
con = new OracleConnection();
Compare(con != null ,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("OracleConnection ctor connection string");
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
Compare(con != null ,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("OracleConnection check connection string");
Compare(con.ConnectionString ,MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,108 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_State : GHTBase
{
public static void Main()
{
OracleConnection_State tc = new OracleConnection_State();
Exception exp = null;
try
{
tc.BeginTest("NoName");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
// ----------- reserved for future versions of the product ---------------
//Broken The connection to the data source is broken. This can occur only after the connection has been opened. A connection in this state may be closed and then re-opened. (This value is reserved for future versions of the product).
//Connecting The connection object is connecting to the data source. (This value is reserved for future versions of the product.) 2
//Executing The connection object is executing a command. (This value is reserved for future versions of the product.) 4
//Fetching The connection object is retrieving data. (This value is reserved for future versions of the product.) 8
//-------------- checking only the following: ----------------
//Closed The connection is closed.
//Open The connection is open.
try
{
BeginCase("ConnectionState Closed");
Compare(con.State ,ConnectionState.Closed );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("ConnectionState Open");
con.Open();
Compare(con.State ,ConnectionState.Open );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
con.Close();
try
{
BeginCase("ConnectionState Closed after open");
Compare(con.State ,ConnectionState.Closed );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,151 @@
//
// Copyright (c) 2006 Mainsoft Co.
//
// 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.OracleClient;
using MonoTests.System.Data.Utils;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnection_StateChange : GHTBase
{
public static void Main()
{
OracleConnection_StateChange tc = new OracleConnection_StateChange();
Exception exp = null;
try
{
tc.BeginTest("OracleConnection_StateChange");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
bool blnEventRaised = false;
ConnectionState OriginalState,CurrentState;
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
// ----------- reserved for future versions of the product ---------------
//Broken The connection to the data source is broken. This can occur only after the connection has been opened. A connection in this state may be closed and then re-opened. (This value is reserved for future versions of the product).
//Connecting The connection object is connecting to the data source. (This value is reserved for future versions of the product.) 2
//Executing The connection object is executing a command. (This value is reserved for future versions of the product.) 4
//Fetching The connection object is retrieving data. (This value is reserved for future versions of the product.) 8
//-------------- checking only the following: ----------------
//Closed The connection is closed.
//Open The connection is open.
//add event handler
con.StateChange +=new StateChangeEventHandler(con_StateChange);
con.Open();
try
{
BeginCase("ConnectionState Closed");
Compare(blnEventRaised,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("OriginalState Closed");
Compare(OriginalState,ConnectionState.Closed );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("CurrentState Open");
Compare(CurrentState,ConnectionState.Open );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
blnEventRaised = false;
con.Close();
try
{
BeginCase("ConnectionState Open");
Compare(blnEventRaised,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("OriginalState Open");
Compare(OriginalState,ConnectionState.Open );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("CurrentState Close");
Compare(CurrentState,ConnectionState.Closed );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
void con_StateChange(Object sender, StateChangeEventArgs e)
{
CurrentState = e.CurrentState ;
OriginalState = e.OriginalState ;
blnEventRaised = true;
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}