Beispiel #1
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);
            }
        }