public override void Run(object context)
        {
            DataSet dataset   = new DataSet();
            String  tableName = TableName.PRODUCT.ToString();

            Command.CommandText = DbDefault.GetAddressQuery();
            int count = 0;

            try
            {
                DataAdapter = Command.CreateDataAdapter();
                dataset     = new DataSet();

                // fill product table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetProductQuery();
                DataAdapter.Fill(dataset, tableName);

                if (dataset.Tables.Count != 1)
                {
                    Fail(String.Format("Tables.Count is incorrect. "
                                       + "Expected [{0}]; Actual [{1}]",
                                       count, dataset.Tables.Count));
                }
                if (dataset.Tables[0].TableName != tableName)
                {
                    Fail(String.Format("TableName is incorrect. "
                                       + "Expected [{0}]; Actual [{1}]",
                                       tableName, dataset.Tables[0].TableName));
                }
                if (dataset.Tables[0].Columns.Count <= 0)
                {
                    Fail(String.Format("Table has {0} columns",
                                       dataset.Tables[0].Columns.Count));
                }
                if (dataset.Tables[0].Rows.Count <= 0)
                {
                    Fail(String.Format("Table has {0} rows",
                                       dataset.Tables[0].Rows.Count));
                }

                ParseDataSet(dataset);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
Exemplo n.º 2
0
        public override void Run(object context)
        {
            DataSet dataset = new DataSet();

            Command.CommandText = DbDefault.GetAddressQuery();
            int count = 0;

            try
            {
                // fill address table
                DataAdapter.Fill(dataset, TableName.ADDRESS.ToString());
                count++;

                // fill supplier table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetSupplierQuery();
                DataAdapter.Fill(dataset, TableName.SUPPLIER.ToString());
                count++;

                // fill category table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetCategoryQuery();
                DataAdapter.Fill(dataset, TableName.CATEGORY.ToString());
                count++;

                // fill product table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetProductQuery();
                DataAdapter.Fill(dataset, TableName.PRODUCT.ToString());
                count++;

                // fill customer table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetCustomerQuery();
                DataAdapter.Fill(dataset, TableName.CUSTOMER.ToString());
                count++;

                // fill order table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetOrderQuery();
                DataAdapter.Fill(dataset, TableName.ORDERS.ToString());
                count++;

                // fill orderdetail table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetOrderDetailQuery();
                DataAdapter.Fill(dataset, TableName.ORDERDETAIL.ToString());
                count++;

                if (dataset.Tables.Count != count)
                {
                    Fail(String.Format("Tables.Count is incorrect. "
                                       + "Expected {0}; Actual {1}",
                                       count, dataset.Tables.Count));
                }

                foreach (DataTable table in dataset.Tables)
                {
                    if (table.Columns.Count <= 0)
                    {
                        Fail(String.Format("Table [{0}] has {1} columns",
                                           table.TableName, table.Columns.Count));
                    }
                    if (table.Rows.Count <= 0)
                    {
                        Fail(String.Format("Table [{0}] has {1} rows",
                                           table.TableName, table.Rows.Count));
                    }
                }

                ParseDataSet(dataset);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }