public void setUp() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { //All tests in this class are only for MSSQLServer. Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType())); return; } if (con == null) { con = new SqlConnection(ConnectedDataProvider.ConnectionStringSQLClient); con.Open(); } }
//[Test] public void DoTestTypes6(OracleConnection conn) { Exception exp = null; DataSet ds = new DataSet(); OracleCommand comm = new OracleCommand("", conn); OracleDataAdapter da = new OracleDataAdapter(); da.SelectCommand = comm; //string tableName = getDbObjectName("Customers",conn); comm.CommandType = CommandType.Text; switch (ConnectedDataProvider.GetDbType(conn)) { case DataBaseServer.SQLServer: case DataBaseServer.Sybase: comm.CommandText = "select * from [Current Product List]"; break; case DataBaseServer.Oracle: case DataBaseServer.PostgreSQL: comm.CommandText = "select * from Current_Product_List"; break; default: comm.CommandText = "select * from DB2ADMIN.Current_Product_List"; break; } ds.Tables.Clear(); da.Fill(ds); try { BeginCase("Testing view"); Compare(ds.Tables[0].Rows.Count > 0, true); Compare(ds.Tables[0].Columns.Count, 2); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
//[Test] public void DoTestThis(OracleConnection con) { Exception exp = null; OracleCommand cmd = new OracleCommand("GH_CREATETABLE", con); cmd.CommandType = CommandType.StoredProcedure; OracleDataAdapter da = new OracleDataAdapter(cmd); DataSet ds = new DataSet(); try { BeginCase("Check effected rows after create table ddl in stored procedure."); int RowsAffected; RowsAffected = cmd.ExecuteNonQuery(); int ExpectedRowsAffected; switch (ConnectedDataProvider.GetDbType(con)) { case DataBaseServer.SQLServer: case DataBaseServer.Sybase: ExpectedRowsAffected = 3; break; case DataBaseServer.Oracle: //In .NET the ExpectedRowsAffected is '1', where as in Java it is '-1', this gap is because of jdbc driver for oracle. ExpectedRowsAffected = -1; break; case DataBaseServer.DB2: ExpectedRowsAffected = -1; break; default: string errMsg = string.Format("GHT: Test not implemented for DB type: {0}", ConnectedDataProvider.GetDbType(con)); throw new NotImplementedException(errMsg); } Compare(RowsAffected, ExpectedRowsAffected); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
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 void TearDown() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { //All tests in this class are only for MSSQLServer. Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType())); return; } if (con != null) { if (con.State == ConnectionState.Open) { con.Close(); } } }
public void TestUsingParametersArray() { //Only apply to MSSQL if ((ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer)) { return; } Exception exp = null; OracleDataReader rdr = null; OracleConnection con = null; DbTypeParametersCollection row = new DbTypeParametersCollection(GUID_TABLE_NAME); string rowId = string.Empty; try { BeginCase("Test using parameters array"); rowId = "43973_" + TestCaseNumber.ToString(); row.Add("UNIQUEIDENTIFIER", new Guid(TEST_GUID_STRING)); row.ExecuteInsert(rowId); row.ExecuteSelectReader(rowId, out rdr, out con); rdr.Read(); Guid guidValue = rdr.GetGuid(0); Compare(guidValue, row[GUID_COLUMN_NAME].Value); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; if ((rdr != null) && (!rdr.IsClosed)) { rdr.Close(); } if (rowId != String.Empty) { row.ExecuteDelete(rowId); } if ((con != null) && (con.State != ConnectionState.Closed)) { con.Close(); } } }
public void SetUp() { Exception exp = null; BeginCase("Setup"); try { con = new OleDbConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); con.Open(); tr = con.BeginTransaction(); cmd = new OleDbCommand("", con, tr); dbServerType = ConnectedDataProvider.GetDbType(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); Assert.AreEqual("Setup", "Setup"); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
public void run() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { //All tests in this class are only for MSSQLServer. Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType())); return; } Exception exp = null; #region ---- Bug 2716 - MSSQL - SqlCommand.Transaction ---- // testing only SQLServerr if (ConnectedDataProvider.GetDbType(con.ConnectionString) != DataBaseServer.SQLServer) { try { BeginCase("Bug 2716 - MSSQL - SqlCommand.Transaction"); SqlCommand comm = new SqlCommand("SELECT * FROM Customers", con); SqlTransaction trans = con.BeginTransaction("transaction"); comm.Transaction = trans; con.Close(); Compare(con.State, ConnectionState.Closed); } catch (Exception ex) { exp = ex; } finally { if (con != null) { if (con.State == ConnectionState.Open) { con.Close(); } } EndCase(exp); exp = null; } } #endregion }
public void run() { OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); con.Open(); //DoTestThis(con); DoTestTypes1(con); //Don't know how to access diffrent database if ((ConnectedDataProvider.GetDbType(con) != DataBaseServer.DB2) && (ConnectedDataProvider.GetDbType(con) != DataBaseServer.PostgreSQL)) { DoTestTypes2(con); DoTestTypes3(con); } #if TARGET_JVM DoTestTypes4(con); #endif // DoTestTypes5(con); //Table direct --> multipe tables DoTestTypes6(con); if ((ConnectedDataProvider.GetDbType(con) != DataBaseServer.Oracle) && (ConnectedDataProvider.GetDbType(con) != DataBaseServer.PostgreSQL)) { DoTestTypes7(con); //Diffrent owner } DoTestTypes8(con); //Diffrent owner //TBD!! //DoTestTypes9(con); if (ConnectedDataProvider.GetDbType(con) != DataBaseServer.PostgreSQL) { DoTestTypes10(con); } CallStoredProcedureInPackage(con); StoredProcedurePackageambiguity_InsidePackage(con); StoredProcedurePackageambiguity_OutsidePackage(con); if (con.State == ConnectionState.Open) { con.Close(); } }
public void run() { #region Simple Tests //string str=""; string sql; OracleConnection con = null; sql = "UPDATE Employees SET Region = :Region, TitleOfCourtesy = :TitleOfCourtesy WHERE EmployeeID=1"; con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); //not testing with DB2 provider if (ConnectedDataProvider.GetDbType(con) != DataBaseServer.DB2) { OracleCommand cmd = new OracleCommand(sql, con); cmd.Parameters.Add(new OracleParameter(":Region", OracleType.VarChar)); cmd.Parameters.Add(new OracleParameter(":TitleOfCourtesy", OracleType.VarChar)); con.Open(); cmd.Parameters[":Region"].Value = "WA"; cmd.Parameters[":TitleOfCourtesy"].Value = "Mr"; //return the number of rows affected int i = cmd.ExecuteNonQuery(); try { BeginCase("Check row count"); Compare(i, 1); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } } if (con.State == ConnectionState.Open) { con.Close(); } #endregion #region Test Parameter Types #region General TypesSubTests(ConnectedDataProvider.GetSimpleDbTypesParameters()); TypesSubTests(ConnectedDataProvider.GetExtendedDbTypesParameters()); #endregion #endregion }
public static void Main() { OracleParameter_ctor_SOtype tc = new OracleParameter_ctor_SOtype(); tc.exp = null; try { tc.BeginTest("OracleParameter_ctor_SOtype on " + ConnectedDataProvider.GetDbType().ToString()); tc.run(); } catch (Exception ex) { tc.exp = ex; } finally { tc.EndTest(tc.exp); } }
//[Test] public void DoTestTypes3(OleDbConnection conn) { BeginCase("Call stored procedure in the different catalog"); nonUniqueId = "48951_" + TestCaseNumber.ToString(); Exception exp = null; DataSet ds = new DataSet(); OleDbCommand comm = new OleDbCommand("", conn); OleDbDataAdapter da = new OleDbDataAdapter(); da.SelectCommand = comm; string tableName = getDbObjectName("Customers", conn, "GHTDB_EX"); int expectedRowsCount = 5; insertIntoStandatTable(conn, tableName, expectedRowsCount, "CustomerID"); comm.CommandType = CommandType.StoredProcedure; comm.CommandText = getDbObjectName("GH_DUMMY", conn, "GHTDB_EX"); switch (ConnectedDataProvider.GetDbType(conn)) { case DataBaseServer.SQLServer: case DataBaseServer.Sybase: comm.Parameters.Add("@CustomerID", nonUniqueId); break; default: comm.Parameters.Add(new OleDbParameter("CustomerIDPrm", OleDbType.Char)); break; } comm.Parameters[0].Value = nonUniqueId; ds.Tables.Clear(); try { da.Fill(ds); Compare(ds.Tables[0].Rows.Count, expectedRowsCount); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; cleanStandatTable(conn, tableName, "CustomerID"); } }
public void TestSetup() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { //All tests in this class are only for MSSQLServer. Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType())); return; } BeginCase("Test Setup"); SqlConnection con = new SqlConnection(ConnectedDataProvider.ConnectionStringSQLClient); StringBuilder createTestSpBuilder = new StringBuilder(); createTestSpBuilder.Append("CREATE PROCEDURE dbo.GHSP_DateTimeOutputTest"); createTestSpBuilder.Append("("); createTestSpBuilder.Append(" @LastRefresh datetime OUTPUT"); createTestSpBuilder.Append(")"); createTestSpBuilder.Append("AS "); createTestSpBuilder.Append("SET @LastRefresh = GETDATE() "); createTestSpBuilder.Append("RETURN"); SqlCommand createTestSpCmd = null; try { createTestSpCmd = new SqlCommand(createTestSpBuilder.ToString(), con); con.Open(); createTestSpCmd.ExecuteNonQuery(); Pass("Test setup completed successfuly."); } catch (Exception ex) { Fail("Test setup failed"); exp = ex; } finally { EndCase(exp); if (con != null && con.State != ConnectionState.Closed) { con.Close(); } } }
public void TestBug4703() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { //All tests in this class are only for MSSQLServer. Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType())); return; } try { BeginCase("Test Bug 4703 - DateTime output parameter of stored procedure contains incorrect time ( always 12:00 AM )"); string strConnection = ConnectedDataProvider.ConnectionStringSQLClient; SqlConnection conn = new SqlConnection(strConnection); conn.Open(); SqlCommand command = conn.CreateCommand(); SqlParameter param = null; command.CommandType = CommandType.StoredProcedure; command.CommandText = "GHSP_DateTimeOutputTest"; param = command.CreateParameter(); param.ParameterName = "@LastRefresh"; param.DbType = DbType.DateTime; param.Direction = ParameterDirection.InputOutput; DateTime testValue = DateTime.Now; param.Value = testValue; command.Parameters.Add(param); Compare(param.Value, testValue); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
public void run() { Exception exp = null; //make database specific test switch (ConnectedDataProvider.GetDbType(con)) { case DataBaseServer.SQLServer: try { BeginCase("check type name"); Compare(typeName == "DBTYPE_I4", true); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } break; case DataBaseServer.Oracle: try { BeginCase("check type name"); Compare(typeName == "DBTYPE_NUMERIC" || typeName == "NUMBER", true); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } break; case DataBaseServer.DB2: try { BeginCase("check type name"); Compare(typeName == "DBTYPE_I4" || typeName == "INTEGER", true); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } break; case DataBaseServer.Unknown: break; } }
//[Test(Description="Call a stored procedure which is defined within a package.")] public void CallStoredProcedureInPackage(OracleConnection con) { if (ConnectedDataProvider.GetDbType(con) != DataBaseServer.Oracle) { //Packages exist only in oracle. return; } Exception exp = null; OracleDataReader rdr = null; try { BeginCase("Call a stored procedure which is defined within a package."); exp = null; DataSet ds = new DataSet(); OracleDataAdapter da = new OracleDataAdapter(); OracleCommand cmd = new OracleCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "ghtpkg.ghsp_inPkg"; cmd.Parameters.Add("CustomerIdPrm", "ALFKI"); cmd.Parameters.Add(new OracleParameter("result", OracleType.Cursor)).Direction = ParameterDirection.Output; da.SelectCommand = cmd; da.Fill(ds); Compare(ds.Tables[0].Rows.Count, 1); } catch (Exception ex) { exp = ex; } finally { if (rdr != null) { rdr.Close(); } EndCase(exp); } }
public void DoTestTimeOnDB2_bug3391() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.DB2) { return; } OracleConnection conn = new OracleConnection(ConnectedDataProvider.ConnectionString); string rowId = string.Empty; try { BeginCase("Test INSERT to TIME column using all of the DateTime"); rowId = "13282_" + this.TestCaseNumber.ToString(); OracleCommand cmd = new OracleCommand(); conn.Open(); cmd.Connection = conn; cmd.CommandText = string.Format("INSERT INTO {0} (ID, T_TIME) VALUES ('{1}', ?)", ConnectedDataProvider.EXTENDED_TYPES_TABLE_NAME, rowId); cmd.Parameters.Add("time", DateTime.Now); try { cmd.ExecuteNonQuery(); ExpectedExceptionNotCaught("System.OracleException"); } catch (OracleException ex) { ExpectedExceptionCaught(ex); } } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; DbTypeParametersCollection.ExecuteDelete(ConnectedDataProvider.EXTENDED_TYPES_TABLE_NAME, rowId); conn.Close(); } }
public void SetUp() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { //All tests in this class are only for MSSQLServer. Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType())); return; } Exception exp = null; BeginCase("Setup"); try { con = new SqlConnection(ConnectedDataProvider.ConnectionStringSQLClient); con.Open(); Compare("Setup", "Setup"); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
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(); } } }
//[Test(Description="Call a stored procedure ghsp_pkgAmbig not from a package, where ghsp_pkgAmbig is defined both inside and outside of a package.")] public void StoredProcedurePackageambiguity_OutsidePackage(OracleConnection con) { if (ConnectedDataProvider.GetDbType(con) != DataBaseServer.Oracle) { //Packages exist only in oracle. return; } Exception exp = null; OracleDataReader rdr = null; try { BeginCase("Call a stored procedure ghsp_pkgAmbig not from a package, where ghsp_pkgAmbig is defined both inside and outside of a package."); exp = null; DataSet ds = new DataSet(); OracleDataAdapter da = new OracleDataAdapter(); OracleCommand cmd = new OracleCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "ghsp_pkgAmbig"; cmd.Parameters.Add(new OracleParameter("res", OracleType.Cursor)).Direction = ParameterDirection.Output; da.SelectCommand = cmd; da.Fill(ds); Compare(ds.Tables[0].Rows[0]["IN_PKG"], "FALSE"); } catch (Exception ex) { exp = ex; } finally { if (rdr != null) { rdr.Close(); } EndCase(exp); } }
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;} */ }
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(); } } }
public void testBug3965() { // testing only SQLServerr if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { Log("This test is relevant only for MSSQLServer!"); return; } Exception exp = null; BeginCase("Test for bug #3965"); OleDbConnection con = new OleDbConnection("Provider=SQLOLEDB.1;Data Source=TESTDIR;User ID=ghuser;Password=ghuser;Persist Security Info=True;Initial Catalog=default_grasshopper_db;Packet Size=4096;Connect Timeout=60"); con.Open(); string text = "SELECT td.TESTCYCL.TC_TEST_ID, td.TESTCYCL.TC_STATUS, td.BUG.BG_STATUS, td.BUG.BG_BUG_ID, td.BUG.BG_USER_03, td.BUG.BG_USER_09,"; text += " td.BUG.BG_USER_10, td.BUG.BG_SUMMARY,BG_DETECTION_VERSION"; text += " FROM td.TESTCYCL INNER JOIN"; text += " td.TEST ON td.TESTCYCL.TC_TEST_ID = td.TEST.TS_TEST_ID INNER JOIN"; text += " td.ALL_LISTS ON td.TEST.TS_SUBJECT = td.ALL_LISTS.AL_ITEM_ID RIGHT OUTER JOIN"; text += " td.BUG ON td.TEST.TS_TEST_ID = td.BUG.BG_TEST_REFERENCE"; OleDbCommand cmd = new OleDbCommand(text, con); try { cmd.ExecuteReader(); Compare(true, true); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); } }
[Test] public void UseQueryAsValue() { string columnName; switch (ConnectedDataProvider.GetDbType()) { case DataBaseServer.SQLServer: columnName = "T_VARCHAR"; break; case DataBaseServer.Oracle: columnName = "T_LONG"; break; case DataBaseServer.DB2: columnName = "T_LONGVARCHAR"; break; default: columnName = "T_VARCHAR"; break; } RunValueInColumnTest(columnName, "SELECT * FROM TYPES_SIMPLE"); }
private string BuildCommandText() { string beginStatement; string endStatement; string commandDelimiter; string[] commands = new string[] { "select * from Customers", "select * from Categories", "select * from Region" }; GetDBSpecificSyntax(ConnectedDataProvider.GetDbType(), out beginStatement, out endStatement, out commandDelimiter); StringBuilder cmdBuilder = new StringBuilder(); cmdBuilder.Append(beginStatement); cmdBuilder.Append(" "); foreach (string statement in commands) { cmdBuilder.Append(statement); cmdBuilder.Append(commandDelimiter); cmdBuilder.Append(" "); } cmdBuilder.Append(endStatement); return(cmdBuilder.ToString()); }
public void TestTearDown() { if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) { //All tests in this class are only for MSSQLServer. Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType())); return; } BeginCase("Test Teardown"); SqlConnection con = new SqlConnection(ConnectedDataProvider.ConnectionStringSQLClient); StringBuilder createTestSpBuilder = new StringBuilder(); string dropTestSpSql = "DROP PROCEDURE dbo.GHSP_DateTimeOutputTest"; SqlCommand dropTestSpCmd = null; try { dropTestSpCmd = new SqlCommand(dropTestSpSql, con); con.Open(); dropTestSpCmd.ExecuteNonQuery(); Pass("Test teardown completed successfuly."); } catch (Exception ex) { Fail("Test teardown failed"); exp = ex; } finally { EndCase(exp); if (con != null && con.State != ConnectionState.Closed) { con.Close(); } } }
public void run() { Exception exp = null; //prepare data OleDbConnection con = new OleDbConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); OleDbCommand cmd = new OleDbCommand("select ProductID,ProductName,Discontinued from Products where ProductID=1", con); con.Open(); OleDbDataReader rdr = cmd.ExecuteReader(); rdr.Read(); object obj = null; switch (ConnectedDataProvider.GetDbType(con)) { case DataBaseServer.DB2: case DataBaseServer.SQLServer: case DataBaseServer.PostgreSQL: try { BeginCase("Column int - type"); obj = rdr["ProductID"]; Compare(obj.GetType().FullName, typeof(int).FullName); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } break; case DataBaseServer.Oracle: case DataBaseServer.Sybase: try { BeginCase("Column Decimal - type"); obj = rdr["ProductID"]; Compare(obj.GetType().FullName, typeof(decimal).FullName); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } break; } try { BeginCase("Column int - value"); Compare(obj.ToString(), "1"); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } try { BeginCase("Column string - type"); obj = rdr["ProductName"]; Compare(obj.GetType().FullName, typeof(string).FullName); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } try { BeginCase("Column string - value"); Compare(obj.ToString(), "Chai"); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } switch (ConnectedDataProvider.GetDbType(con)) { case DataBaseServer.DB2: try { BeginCase("Column Int16 - type"); obj = rdr["Discontinued"]; Compare(obj.GetType().FullName, typeof(Int16).FullName); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } try { BeginCase("Column Int16 - value"); Compare(obj.ToString(), "0"); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } break; case DataBaseServer.SQLServer: try { BeginCase("Column bool - type"); obj = rdr["Discontinued"]; Compare(obj.GetType().FullName, typeof(bool).FullName); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } try { BeginCase("Column bool - value"); Compare(obj.ToString().ToUpper(), "FALSE"); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } break; case DataBaseServer.Oracle: //Column type is Decimal - already tested break; } if (con.State == ConnectionState.Open) { 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); }
public void run() { Exception exp = null; MonoTests.System.Data.Utils.DataBaseServer dbServer = ConnectedDataProvider.GetDbType(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); OleDbConnection con = new OleDbConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); OleDbTransaction txn = null; try { BeginCase("IsolationLevel = ReadCommitted"); con.Open(); txn = con.BeginTransaction(); Compare(txn.IsolationLevel, IsolationLevel.ReadCommitted); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; if (con.State == ConnectionState.Open) { con.Close(); } } //not supported in Oracle if (dbServer != MonoTests.System.Data.Utils.DataBaseServer.Oracle) { try { BeginCase("IsolationLevel = ReadUncommitted"); con.Open(); txn = con.BeginTransaction(IsolationLevel.ReadUncommitted); Compare(txn.IsolationLevel, IsolationLevel.ReadUncommitted); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; if (con.State == ConnectionState.Open) { con.Close(); } } } //not supported in Oracle if (dbServer != MonoTests.System.Data.Utils.DataBaseServer.Oracle) { try { BeginCase("IsolationLevel = RepeatableRead"); con.Open(); txn = con.BeginTransaction(IsolationLevel.RepeatableRead); Compare(txn.IsolationLevel, IsolationLevel.RepeatableRead); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; if (con.State == ConnectionState.Open) { con.Close(); } } } try { BeginCase("IsolationLevel = Serializable"); con.Open(); txn = con.BeginTransaction(IsolationLevel.Serializable); Compare(txn.IsolationLevel, IsolationLevel.Serializable); txn.Rollback(); txn = con.BeginTransaction(); txn.Rollback(); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; if (con.State == ConnectionState.Open) { con.Close(); } } // not supported in DB2,MSSQL,Oracle,sybase and guess what... Postgres. if (dbServer != MonoTests.System.Data.Utils.DataBaseServer.DB2 && dbServer != MonoTests.System.Data.Utils.DataBaseServer.SQLServer && dbServer != MonoTests.System.Data.Utils.DataBaseServer.Oracle && dbServer != DataBaseServer.PostgreSQL && dbServer != MonoTests.System.Data.Utils.DataBaseServer.Sybase) { try { BeginCase("IsolationLevel = Unspecified"); con.Open(); txn = con.BeginTransaction(IsolationLevel.Unspecified); Compare(txn.IsolationLevel, IsolationLevel.Unspecified); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; if (con.State == ConnectionState.Open) { con.Close(); } } } }
public void run() { Log(string.Format("DB Server={0}.", ConnectedDataProvider.GetDbType())); AllTypes(); SimpleTypesWithDBNull(); }