예제 #1
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Category category = dbc.GetRandomCategory();
                Supplier supplier = dbc.GetRandomSupplier();

                Product product = (Product)ObjectFactory.Create(ObjectType.Product);
                product.Category = category;
                product.Supplier = supplier;
                dbc.AddProduct(product);

                Product result = dbc.GetProduct(product.ProductId);
                if (result == null)
                {
                    Fail("Failed to insert new Product record");
                    return;
                }
                else if (!product.Equals(result))
                {
                    Fail("Inserted Product record having inconsistent data");
                    return;
                }

                product           = (Product)ObjectFactory.Create(ObjectType.Product);
                product.ProductId = result.ProductId;
                dbc.UpdateProduct(product);

                result = dbc.GetProduct(product.ProductId);
                if (!product.Equals(result))
                {
                    Fail("Failed to update Product record");
                }

                dbc.DeleteProduct(product.ProductId);
                if (dbc.GetProduct(product.ProductId) != null)
                {
                    Fail("Failed to delete Product record");
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Category category = dbc.GetRandomCategory();
                Supplier supplier = dbc.GetRandomSupplier();

                Product product = (Product)ObjectFactory.Create(ObjectType.Product);
                product.Category = category;
                product.Supplier = supplier;
                dbc.AddProduct(product);

                Product result = dbc.GetProduct(product.ProductId);
                if (result == null)
                {
                    Fail("Failed to insert new Product record");
                    return;
                }
                else if (!product.Equals(result))
                {
                    Fail("Inserted Product record having inconsistent data");
                    return;
                }

                product = (Product)ObjectFactory.Create(ObjectType.Product);
                product.ProductId = result.ProductId;
                dbc.UpdateProduct(product);

                result = dbc.GetProduct(product.ProductId);
                if (!product.Equals(result))
                    Fail("Failed to update Product record");

                dbc.DeleteProduct(product.ProductId);
                if (dbc.GetProduct(product.ProductId) != null)
                    Fail("Failed to delete Product record");
                
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
예제 #3
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                dbc.DeleteProduct(dbc.GetRandomOrderDetail().ProductId);
                Fail("OrderDetail constraint violation exception shoudl have occurred");
            }
            catch (Exception e)
            {
                Log(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                dbc.DeleteProduct(dbc.GetRandomOrderDetail().ProductId);
                Fail("OrderDetail constraint violation exception shoudl have occurred");
            }
            catch (Exception e)
            {
                Log(e);
            }
            finally
            {
                base.Run(context);
            }
        }