public void TestDtoToOrder()
        {
            OrderDetailDTO detailDto = new OrderDetailDTO()
            {
                Id = 1, QuantityInUnits = 123, UnitPrice = 213, ProductId = 1, ProductName = "FAkeProduct", Version = 1
            };
            OrderDTO dto = new OrderDTO()
            {
                Id = 1, OrderStatus = OrderStatus.Ordered, OrderDate = DateTime.Now, ShippedDate = null, CustomerId = 123, CustomerName = "Fakecustomer"
            };

            dto.Details.Add(detailDto);
            Assert.AreEqual(true, dto.IsValid);
            Assert.AreEqual(true, detailDto.IsValid);

            Order order = OrderAdapter.DtoToOrder(dto);

            Assert.AreEqual <int>(dto.Id, order.OrderId);
            Assert.AreEqual <int>((int)dto.OrderStatus, (int)order.OrderStatus);
            Assert.AreEqual <DateTime?>(dto.OrderDate, order.OrderDate);
            Assert.AreEqual <DateTime?>(dto.ShippedDate, order.ShippedDate);
            Assert.AreEqual <int>(dto.CustomerId, order.Customer.CustomerId);
            //TODO: Assert.AreEqual<string>(dto.CustomerName, order.Customer.Username);
            Assert.AreEqual(dto.Version, order.Version);

            //TODO: Assert.AreEqual<int>(dto.Details.Count(), order.Details.Count());
            Assert.AreEqual(true, order.IsValid);
        }
예제 #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);
        }