public override void Run(object context) { GFXDDataReader reader = null; String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); Command.CommandText = String.Format("SELECT * FROM {0}", tableName); reader = Command.ExecuteReader(); if (reader == null) { Fail("DataReader is null"); } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { int updateSize = 5; DataTable[] tables = new DataTable[updateSize]; String[] tableNames = new String[updateSize]; try { Connection.AutoCommit = false; Connection.BeginGFXDTransaction(IsolationLevel.Chaos); IList <object> data = DbRandom.GetRandomRowData(); for (int i = 0; i < updateSize; i++) { tableNames[i] = DbRandom.BuildRandomTable(5); Command.CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableNames[i]); DataAdapter = Command.CreateDataAdapter(); tables[i] = new DataTable(); DataAdapter.Fill(tables[i]); CommandBuilder = new GFXDCommandBuilder(DataAdapter); for (int j = 0; j < tables[i].Rows.Count; j++) { for (int k = 1; k < tables[i].Columns.Count; k++) { tables[i].Rows[j][k] = data[k]; } } if (DataAdapter.Update(tables[i]) != tables[i].Rows.Count) { Fail(String.Format( "Failed to update table {0}", tableNames[i])); } } Connection.Commit(); } catch (Exception e) { Fail(e); } finally { foreach (String tableName in tableNames) { DbRandom.DropTable(tableName); } base.Run(context); } }
public override void Run(object context) { String tableName = null; try { tableName = DbRandom.BuildRandomTable(5); int colCount = DbHelper.GetTableColumnCount(tableName); Command.CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableName); DataReader = Command.ExecuteReader(); while (DataReader.Read()) { StringBuilder row = new StringBuilder(); for (int i = 0; i < colCount; i++) { try { String data = DataReader.GetString(i); if (data == null && data == String.Empty) { Fail("GetString() failed to retrieve column data"); } row.Append(data); row.Append(", "); } catch (Exception e) { Fail(e); } } Log(row.ToString()); } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); int colCount = DbHelper.GetTableColumnCount(tableName); Command.CommandText = "SELECT * FROM " + tableName; DataReader = Command.ExecuteReader(); while (DataReader.Read()) { StringBuilder row = new StringBuilder(); try { object[] data = new object[colCount]; int ret = DataReader.GetValues(data); foreach (object o in data) { if (o == null) { Fail("GetValues() failed to retrieve the column values"); } row.Append(o.ToString()); row.Append(", "); } Log(row.ToString()); } catch (Exception e) { Fail(e); } } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); int colCount = DbHelper.GetTableColumnCount(tableName); Command.CommandText = "SELECT * FROM " + tableName; DataReader = Command.ExecuteReader(); while (DataReader.Read()) { StringBuilder row = new StringBuilder(); try { for (int i = 0; i < colCount; i++) { object data = DataReader.GetValue(i); if (data == null) { Fail("GetValue() failed to retrieve a column value"); } row.Append(data.ToString()); row.Append(", "); } Log(row.ToString()); } catch (Exception e) { Fail(e); } } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); int colCount = DbHelper.GetTableColumnCount(tableName); Command.CommandText = String.Format("SELECT * FROM {0}", tableName); DataTable table = DataReader.GetSchemaTable(); if (table.Rows.Count != DataReader.FieldCount) { Fail(String.Format("GetSchemaTable() returns incorrect number of rows. " + "Expected [{0}]; Actual [{1}]", table.Rows.Count, DataReader.FieldCount)); } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Log(e); } base.Run(context); } }
public override void Run(object context) { int updateSize = 5; DataTable[] tables = new DataTable[updateSize]; String[] tableNames = new String[updateSize]; GFXDClientConnection[] conns = new GFXDClientConnection[updateSize]; GFXDCommand[] cmds = new GFXDCommand[updateSize]; GFXDDataAdapter[] adpts = new GFXDDataAdapter[updateSize]; try { for (int i = 0; i < updateSize; i++) { tableNames[i] = DbRandom.BuildRandomTable(5); conns[i] = new GFXDClientConnection(ConnectionString); cmds[i] = conns[i].CreateCommand(); cmds[i].CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableNames[i]); conns[i].Open(); conns[i].AutoCommit = false; conns[i].BeginGFXDTransaction(); adpts[i] = cmds[i].CreateDataAdapter(); tables[i] = new DataTable(); adpts[i].Fill(tables[i]); ParseDataTable(tables[i]); } IList <object> data = DbRandom.GetRandomRowData(); for (int i = 0; i < updateSize; i++) { CommandBuilder = new GFXDCommandBuilder(adpts[i]); for (int j = 0; j < tables[i].Rows.Count; j++) { for (int k = 1; k < tables[i].Columns.Count; k++) { tables[i].Rows[j][k] = data[k]; } } if (adpts[i].Update(tables[i]) != tables[i].Rows.Count) { Fail(String.Format( "Failed to update table {0}", tableNames[i])); } try { conns[i].Commit(); } catch (Exception e) { conns[i].Rollback(); Fail(e); } } for (int i = 0; i < updateSize; i++) { tables[i].Clear(); adpts[i].Fill(tables[i]); } foreach (DataTable table in tables) { foreach (DataRow row in table.Rows) { for (int i = 1; i < row.Table.Columns.Count; i++) { if (!DbRandom.Compare(data[i], row, i)) { Fail(String.Format( "Inconsistent updated data in table [{0}] at row [{1}] column [{2}]. " + "Expected [{3}]; Actual [{4}]", table.TableName, row[0].ToString(), row.Table.Columns[i].ColumnName, data[i].ToString(), row[i].ToString())); } } } } } catch (Exception e) { Fail(e); } finally { foreach (String tableName in tableNames) { DbRandom.DropTable(tableName); } base.Run(context); } }
public override void Run(object context) { DataTable table = new DataTable(); String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); Command.CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableName); DataAdapter.Fill(table); CommandBuilder = new GFXDCommandBuilder(DataAdapter); IList <object> data = DbRandom.GetRandomRowData(); for (int i = 0; i < table.Rows.Count; i++) { for (int j = 1; j < data.Count; j++) // do not update identity column { table.Rows[i][j] = data[j]; } } int rowsUpdated = DataAdapter.Update(table); if (rowsUpdated != table.Rows.Count) { Fail(String.Format("Failed to update all changed rows. " + "Expected [{0}]; Actual [{1}]", rowsUpdated, table.Rows.Count)); } table.Clear(); DataAdapter.Fill(table); foreach (DataRow row in table.Rows) { for (int i = 1; i < row.Table.Columns.Count; i++) { if (!DbRandom.Compare(data[i], row, i)) { Fail(String.Format( "Inconsistent updated data at row [{0}] column [{1}]. " + "Expected [{2}]; Actual [{3}]", row[0].ToString(), row.Table.Columns[i].ColumnName, data[i].ToString(), row[i].ToString())); } } } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { DataTable table = new DataTable(); String tableName = null; int rowsToInsert = 10; try { tableName = DbRandom.BuildRandomTable(10); Command.CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableName); DataAdapter.Fill(table); GFXDCommandBuilder builder = new GFXDCommandBuilder(DataAdapter); DataAdapter.InsertCommand = builder.GetInsertCommand(); DataAdapter.UpdateCommand = builder.GetUpdateCommand(); DataAdapter.DeleteCommand = builder.GetDeleteCommand(); if (!DataAdapter.AcceptChangesDuringFill) { DataAdapter.AcceptChangesDuringFill = true; } if (!DataAdapter.AcceptChangesDuringUpdate) { DataAdapter.AcceptChangesDuringUpdate = true; } IList <object> data = DbRandom.GetRandomRowData(); long lastRowId = long.Parse(table.Rows[table.Rows.Count - 1][0].ToString()); for (int i = 0; i < rowsToInsert; i++) { DataRow row = table.NewRow(); row[0] = lastRowId + i + 1; for (int j = 1; j < data.Count; j++) { row[j] = data[j]; } table.Rows.Add(row); } int rowsUpdated = DataAdapter.Update(table); if (rowsUpdated != rowsToInsert) { Fail(String.Format("Failed to update all changed rows. " + "Expected [{0}]; Actual [{1}]", rowsToInsert, rowsUpdated)); } table.Clear(); DataAdapter.Fill(table); foreach (DataRow row in table.Rows) { if (long.Parse(row[0].ToString()) > lastRowId) { for (int i = 1; i < row.Table.Columns.Count; i++) { if (!DbRandom.Compare(data[i], row, i)) { Fail(String.Format("Inconsistent updated data at row [{0}] column [{1}]. " + "Expected [{2}]; Actual [{3}]", row[0].ToString(), row.Table.Columns[i].ColumnName, data[i].ToString(), row[i].ToString())); } } } } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { int updateSize = 5; DataTable[] tables = new DataTable[updateSize]; String[] tableNames = new String[updateSize]; try { Connection.AutoCommit = false; Connection.BeginGFXDTransaction(IsolationLevel.Chaos); //Connection.ReadOnly = false; // CHANGED Command.ReaderUpdatable = true; object[] data = DbRandom.GetRandomRowData().ToArray <object>(); for (int i = 0; i < updateSize; i++) { tableNames[i] = DbRandom.BuildRandomTable(5); Command.CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableNames[i]); DataReader = Command.ExecuteReader(); while (DataReader.Read()) { // CHANGED DataReader.UpdateValues(data); } // CHANGED DataReader.UpdateRow(); } Connection.Commit(); for (int i = 0; i < updateSize; i++) { Command.CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableNames[i]); DataReader = Command.ExecuteReader(); while (DataReader.Read()) { for (int j = 1; j < DataReader.FieldCount; j++) { if (DataReader.GetString(j) != data[j].ToString()) { Fail("Failed to commit DataReader update transaction."); } } } } } catch (Exception e) { Connection.Rollback(); Fail(e); } finally { foreach (String tableName in tableNames) { DbRandom.DropTable(tableName); } base.Run(context); } }
public override void Run(object context) { int dsSize = 10; DataSet dataset = new DataSet(); String[] tableNames = new String[dsSize]; GFXDCommand[] commands = new GFXDCommand[dsSize]; GFXDDataAdapter[] adapters = new GFXDDataAdapter[dsSize]; try { for (int i = 0; i < dsSize; i++) { tableNames[i] = DbRandom.BuildRandomTable(5); commands[i] = Connection.CreateCommand(); commands[i].CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableNames[i]); adapters[i] = commands[i].CreateDataAdapter(); adapters[i].Fill(dataset, tableNames[i]); } ParseDataSet(dataset); IList <object> data = DbRandom.GetRandomRowData(); for (int i = 0; i < dsSize; i++) { CommandBuilder = new GFXDCommandBuilder(adapters[i]); for (int j = 0; j < dataset.Tables[tableNames[i]].Rows.Count; j++) { for (int k = 1; k < dataset.Tables[tableNames[i]].Columns.Count; k++) // do not update identity column { dataset.Tables[tableNames[i]].Rows[j][k] = data[k]; } } if (adapters[i].Update(dataset, tableNames[i]) != dataset.Tables[tableNames[i]].Rows.Count) { Fail(String.Format( "Failed to update all changed rows in table {0}", tableNames[i])); } } dataset.Clear(); for (int i = 0; i < dsSize; i++) { adapters[i].Fill(dataset, tableNames[i]); } ParseDataSet(dataset); foreach (DataTable table in dataset.Tables) { foreach (DataRow row in table.Rows) { for (int i = 1; i < row.Table.Columns.Count; i++) { if (!DbRandom.Compare(data[i], row, i)) { Fail(String.Format( "Inconsistent updated data in table [{0}] at row [{1}] column [{2}]. " + "Expected [{3}]; Actual [{4}]", table.TableName, row[0].ToString(), row.Table.Columns[i].ColumnName, data[i].ToString(), row[i].ToString())); } } } } } catch (Exception e) { Fail(e); } finally { try { foreach (String tableName in tableNames) { DbRandom.DropTable(tableName); } } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { DataTable table = new DataTable(); String tableName = null;; try { Connection.AutoCommit = false; Connection.BeginGFXDTransaction(IsolationLevel.Chaos); tableName = DbRandom.BuildRandomTable(10); Command.CommandText = String.Format( "SELECT * FROM {0} ORDER BY COL_ID ASC ", tableName); // Adapter update DataAdapter.Fill(table); CommandBuilder = new GFXDCommandBuilder(DataAdapter); IList <object> adptData = DbRandom.GetRandomRowData(); for (int i = 0; i < table.Rows.Count; i++) { for (int j = 1; j < adptData.Count; j++) // do not update identity column { table.Rows[i][j] = adptData[j]; } } int rowsUpdated = DataAdapter.Update(table); if (rowsUpdated != table.Rows.Count) { Fail(String.Format("Failed to update all changed rows. " + "Expected [{0}]; Actual [{1}]", rowsUpdated, table.Rows.Count)); } // Reader update //Connection.ReadOnly = false; // CHANGED Command.ReaderUpdatable = true; object[] rdrData = DbRandom.GetRandomRowData().ToArray <object>(); DataReader = Command.ExecuteReader(); while (DataReader.Read()) { // CHANGED DataReader.UpdateValues(rdrData); } // CHANGED DataReader.UpdateRow(); Connection.Commit(); } catch (Exception e) { Connection.Rollback(); Fail(e); } finally { DbRandom.DropTable(tableName); base.Run(context); } }
public override void Run(object context) { String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); int colCount = DbHelper.GetTableColumnCount(tableName); Command.CommandText = "SELECT * FROM " + tableName; DataReader = Command.ExecuteReader(); while (DataReader.Read()) { StringBuilder row = new StringBuilder(); for (int i = 0; i < colCount; i++) { try { switch (DataReader.GetDataTypeName(i)) { case "INTEGER": row.Append(DataReader.GetInt32(i)); break; case "BIGINT": row.Append(DataReader.GetInt64(i)); break; case "CHAR": row.Append(DataReader.GetChar(i)); break; case "DATE": row.Append(DataReader.GetDateTime(i)); break; case "DECIMAL": row.Append(DataReader.GetDecimal(i)); break; case "DOUBLE": row.Append(DataReader.GetDouble(i)); break; case "LONG VARCHAR": row.Append(DataReader.GetChars(i, 0, 0)); break; case "REAL": row.Append(DataReader.GetDecimal(i)); break; case "SMALLINT": row.Append(DataReader.GetInt16(i)); break; case "TIME": DateTime dt = DataReader.GetDateTime(i); Log(String.Format("DateTime.Kind = {0}", dt.Kind)); row.Append(DataReader.GetDateTime(i)); break; case "TIMESTAMP": row.Append(DataReader.GetDateTime(i)); break; case "VARCHAR": row.Append(DataReader.GetChars(i, 0, 0)); break; case "CHAR FOR BIT DATA": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "VARCHAR FOR BIT DATA": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "LONG VARCHAR FOR BIT DATA": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "BLOB": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "CLOB": row.Append(DataReader.GetChars(i, 0, 0)); break; default: row.Append("UNKNOWN"); break; } row.Append(", "); } catch (Exception e) { Fail(e); } } Log(row.ToString()); } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }