예제 #1
0
        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);
            }
        }
예제 #2
0
        public override void Run(object context)
        {
            Object[] parameters = DbRandom.GetRandomRowData().ToArray <Object>();

            try
            {
                Command.Parameters.AddRange(parameters);

                if (Command.Parameters.Count != parameters.Length)
                {
                    Fail(String.Format("Failed to add array of objects to Parameters collection. "
                                       + "Expected [{0}]; Actual [{1}]",
                                       parameters.Length, Command.Parameters.Count));
                }
                for (int i = 0; i < parameters.Length; i++)
                {
                    if (Command.Parameters[i].ToString() != parameters[i].ToString())
                    {
                        Fail(String.Format("Parameter value is incorrectly added. "
                                           + "Expected [{0}]; Actual [{1}]",
                                           parameters[i].ToString(), Command.Parameters[i].ToString()));
                    }
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                try
                {
                    Command.Close();
                }
                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];
            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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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.Rollback();

                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 rollback DataReader update transaction.");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            String tableName = null;

            object[] newVals;

            try
            {
                tableName = DbRandom.BuildRandomTable(10);

                int colCount = DbHelper.GetTableColumnCount(tableName);

                Command.CommandText = String.Format(
                    "SELECT * FROM {0} ORDER BY COL_ID DESC FETCH FIRST 1 ROWS ONLY",
                    tableName);

                //Connection.ReadOnly = false;
                // CHANGED Command.ReaderUpdatable = true;

                DataReader = Command.ExecuteReader();
                newVals    = DbRandom.GetRandomRowData().ToArray <object>();

                if (!DataReader.Read())
                {
                    Fail("Reader returns no record");
                }

                // CHANGED DataReader.UpdateValues(newVals);
                // CHANGED DataReader.UpdateRow();

                DataReader = Command.ExecuteReader();
                while (DataReader.Read())
                {
                    for (int i = 0; i < colCount; i++)
                    {
                        object data = DataReader.GetValue(i);
                        if (DataReader.GetValue(i) != newVals[i])
                        {
                            Fail(String.Format("UpdateValues() failed to update column {0} value "
                                               + "Expected [{1}]; Actual [{2}]",
                                               newVals[i].ToString(), data.ToString()));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                try
                {
                    DbHelper.DropTable(tableName);
                }
                catch (Exception e)
                {
                    Fail(e);
                }

                base.Run(context);
            }
        }
예제 #8
0
        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);
            }
        }