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

            try
            {
                Order   order   = dbc.GetRandomOrder();
                Product product = dbc.GetRandomProduct();

                OrderDetail ordDetail = (OrderDetail)ObjectFactory.Create(ObjectType.OrderDetail);
                ordDetail.OrderId   = order.OrderId;
                ordDetail.ProductId = product.ProductId;
                dbc.AddOrderDetail(ordDetail);

                OrderDetail result = dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (result == null)
                {
                    Fail("Failed to insert new OrderDetail record");
                    return;
                }
                else if (!ordDetail.Equals(result))
                {
                    Fail("Inserted OrderDetail record having inconsistent data");
                    return;
                }

                ordDetail           = (OrderDetail)ObjectFactory.Create(ObjectType.OrderDetail);
                ordDetail.OrderId   = result.OrderId;
                ordDetail.ProductId = result.ProductId;
                dbc.UpdateOrderDetail(ordDetail);

                result = dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (!ordDetail.Equals(result))
                {
                    Fail("Failed to update OrderDetail record");
                    return;
                }

                dbc.DeleteOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId) != null)
                {
                    Fail("Failed to delete OrderDetail record");
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Order order = dbc.GetRandomOrder();
                Product product = dbc.GetRandomProduct();

                OrderDetail ordDetail = (OrderDetail)ObjectFactory.Create(ObjectType.OrderDetail);
                ordDetail.OrderId = order.OrderId;
                ordDetail.ProductId = product.ProductId;
                dbc.AddOrderDetail(ordDetail);

                OrderDetail result = dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (result == null)
                {
                    Fail("Failed to insert new OrderDetail record");
                    return;
                }
                else if (!ordDetail.Equals(result))
                {
                    Fail("Inserted OrderDetail record having inconsistent data");
                    return;
                }

                ordDetail = (OrderDetail)ObjectFactory.Create(ObjectType.OrderDetail);
                ordDetail.OrderId = result.OrderId;
                ordDetail.ProductId = result.ProductId;
                dbc.UpdateOrderDetail(ordDetail);

                result = dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (!ordDetail.Equals(result))
                {
                    Fail("Failed to update OrderDetail record");
                    return;
                }

                dbc.DeleteOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId) != null)
                    Fail("Failed to delete OrderDetail record");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }