Example #1
0
        public void TestStoreOrder()
        {
            int orderId = 123;
            OrderBusinessComponent service = new OrderBusinessComponent(this.context);
            Order order = new Order()
            {
                OrderId = orderId
            };
            List <ChangeItem> changeItems = new List <ChangeItem>
            {
                new ChangeItem(ChangeType.ChildInsert, new OrderDetail()),
                new ChangeItem(ChangeType.ChildUpate, new OrderDetail()),
                new ChangeItem(ChangeType.ChildDelete, new OrderDetail())
            };

            Expect.Once.On(context).Method("SaveOrder").Will(Return.Value(orderId));
            Expect.Once.On(context).Method("SaveOrderDetail").Will(Return.Value(1));
            Expect.Once.On(context).Method("SaveOrderDetail").Will(Return.Value(1));
            Expect.Once.On(context).Method("DeleteOrderDetail");
            int resultOrderId = service.StoreOrder(order, changeItems);

            Assert.AreEqual <int>(orderId, resultOrderId);

            mockBuilder.VerifyAllExpectationsHaveBeenMet();
        }
Example #2
0
        public StoreOrderResponse StoreOrder(StoreOrderRequest request)
        {
            StoreOrderResponse     response = new StoreOrderResponse();
            OrderBusinessComponent bc       = DependencyInjectionHelper.GetOrderBusinessComponent();

            Order order = OrderAdapter.DtoToOrder(request.Order);
            IEnumerable <ChangeItem> changeItems = OrderAdapter.GetChangeItems(request.Order, order);

            response.Id = bc.StoreOrder(order, changeItems);

            return(response);
        }