public static Order GetPopulatedOrder() { Order order = new Order(); order.Approver = "11"; order.Creator = "11"; order.CustomerId = "100"; order.ShipAddress = "225 112th NE Street"; order.ShipCity = "Bellevue"; order.ShipRegion = "Washington"; order.ShipPostalCode = "98005"; order.OrderName = "ORDER1"; order.Description = "Needs it quick"; order.Details = new List<OrderDetail>(); order.Details.Add(new OrderDetail(0, 1, 2, 5.95m)); order.Details.Add(new OrderDetail(0, 2, 4, 1.25m)); return order; }
public void OnViewInitializedShouldDisplayNewOrderInNewOrderFlow() { Order order = new Order(); order.OrderStatus = (int)OrderStatusEnum.Draft; controller.CurrentOrder = order; presenter.OnViewInitialized(); Assert.IsTrue(String.IsNullOrEmpty(view.CustomerName)); Assert.AreEqual("Draft", view.OrderNumber); }
private Order TranslateFromOrdersRowToOrderEntityWithDetails(OrdersManagementDataSet.OrdersRow ordersRow) { OrdersManagementDataSet.OrderDetailsRow[] detailRows = ordersRow.GetOrderDetailsRows(); Order order = new Order(); TranslateFromOrdersRowToOrderEntity(ordersRow, order); order.Details = new List<OrderDetail>(detailRows.Length); foreach (OrdersManagementDataSet.OrderDetailsRow detailRow in detailRows) { Product product = _productService.GetProductById(detailRow.ProductId); OrderDetail detail = new OrderDetail(detailRow.OrderId, detailRow.ProductId, detailRow.Quantity, product.UnitPrice.Value); order.Details.Add(detail); } return order; }
private int PersistOrder(Order order, int newStatus) { OrdersManagementDataSet.OrdersRow ordersRow; if (order.OrderId <= 0) { ordersRow = repository.Orders.NewOrdersRow(); } else { ordersRow = repository.Orders.FindByOrderId(order.OrderId); foreach (OrdersManagementDataSet.OrderDetailsRow detailRow in ordersRow.GetOrderDetailsRows()) { detailRow.Delete(); } } TranslateFromOrderEntityToOrdersRow(order, ordersRow); ordersRow.OrderStatus = newStatus; if (order.Details != null) { foreach (OrderDetail detail in order.Details) { OrdersManagementDataSet.OrderDetailsRow detailRow = repository.OrderDetails.NewOrderDetailsRow(); detailRow.OrdersRow = ordersRow; detailRow.ProductId = detail.ProductId; detailRow.Quantity = detail.Quantity; repository.OrderDetails.AddOrderDetailsRow(detailRow); } } if (order.OrderId <= 0) repository.Orders.AddOrdersRow(ordersRow); int newOrderId = ordersRow.OrderId; return newOrderId; }
public void ShouldShowOrderOnInitialize() { Order order = new Order(1, "OrderName", "CustomerId", "EmployeeId", "Description", (int)OrderStatusEnum.Draft, null, null, null, null, null, null, null); order.Details.Add(new OrderDetail(1, 1, 10, 15.0m)); order.Details.Add(new OrderDetail(1, 2, 20, 30.5m)); productService.AddProduct(new Product(1, "1111-11111", "Product A", 15.0m, null)); productService.AddProduct(new Product(2, "2222-22222", "Product B", 30.5m, null)); presenter.OnShowOrder(order); Assert.IsTrue(view.ShowOrderInfoCalled); Assert.IsNotNull(view.OrderInfoShown); Assert.IsNotNull(view.OrderItemLinesShown); Assert.AreEqual(2, view.OrderItemLinesShown.Count); }
public void OnInitializedSetsOrdersInView() { httpContextLocatorService.MockHttpContext.User = new GenericPrincipal(new GenericIdentity("empl1"), null); ordersService.GetSavedDraftOrdersList = new List<Order>(); ordersService.GetSavedDraftOrdersList.Add(new Order(1, "name1", "cust1", "empl1", "desc1", (int)OrderStatusEnum.Draft, null, null, null, null, null, null, null)); ordersService.GetSavedDraftOrdersList.Add(new Order(2, "name2", "cust2", "empl1", "desc2", (int)OrderStatusEnum.Draft, null, null, null, null, null, null, null)); Order orderWithDetails = new Order(3, "name3", "cust3", "empl1", "desc3", (int)OrderStatusEnum.Draft, null, null, null, null, null, null, null); orderWithDetails.Details.Add(new OrderDetail(3, 1, 2, 2.25m)); ordersService.GetSavedDraftOrdersList.Add(orderWithDetails); presenter.OnViewInitialized(); Assert.IsNotNull(view.Orders); Assert.AreEqual(3, view.Orders.Count); IEnumerator<OrderInfo> enumerator = view.Orders.GetEnumerator(); enumerator.Reset(); enumerator.MoveNext(); Assert.AreEqual("1", enumerator.Current.OrderId); Assert.AreEqual("name1", enumerator.Current.OrderName); enumerator.MoveNext(); Assert.AreEqual("desc2", enumerator.Current.Description); enumerator.MoveNext(); Assert.AreEqual(4.50m, enumerator.Current.OrderTotal); }
public void OnDeleteOrderUseOrdersServiceAndReloadOrders() { httpContextLocatorService.MockHttpContext.User = new GenericPrincipal(new GenericIdentity("empl1"), null); ordersService.GetSavedDraftOrdersList = new List<Order>(); ordersService.GetSavedDraftOrdersList.Add(new Order(1, "name1", "cust1", "empl1", "desc1", (int)OrderStatusEnum.Submitted, null, null, null, null, null, null, null)); ordersService.GetSavedDraftOrdersList.Add(new Order(2, "name2", "cust2", "empl1", "desc2", (int)OrderStatusEnum.Submitted, null, null, null, null, null, null, null)); Order orderWithDetails = new Order(3, "name3", "cust3", "empl1", "desc3", (int)OrderStatusEnum.Submitted, null, null, null, null, null, null, null); orderWithDetails.Details.Add(new OrderDetail(3, 1, 2, 2.25m)); ordersService.GetSavedDraftOrdersList.Add(orderWithDetails); presenter.OnViewInitialized(); // Set expected orders before calling DeleteOrder ordersService.GetSavedDraftOrdersList.RemoveAt(1); ordersService.GetSavedDraftOrdersCalled = false; view.OrdersAssigned = false; presenter.OnDeleteOrder("2"); Assert.IsTrue(ordersService.DeleteOrderCalled); Assert.AreEqual(2, ordersService.DeleteOrderArgumentValue); Assert.IsTrue(ordersService.GetSavedDraftOrdersCalled); Assert.IsTrue(view.OrdersAssigned); Assert.AreEqual(2, view.Orders.Count); IEnumerator<OrderInfo> enumerator = view.Orders.GetEnumerator(); enumerator.Reset(); enumerator.MoveNext(); Assert.AreEqual("1", enumerator.Current.OrderId); enumerator.MoveNext(); Assert.AreEqual("3", enumerator.Current.OrderId); }
public void StartLoadOrderFlow(int orderId) { StartLoadOrderFlowCalled = true; CurrentOrder = OrderToLoad; LoadedOrderId = orderId; }
public MockOrdersController() { _currentOrder = new Order(); }
public void SubmitOrder(Order order) { SubmitOrderCalled = true; }
public void OnViewInitializedShouldDisplayOrderDetailsInLoadOrderFlow() { Order order = new Order(); order.Details = new List<OrderDetail>(); order.Details.Add(new OrderDetail(1, 1, 2, 2.95m)); productService.AddProduct(new Product(1, "1234", "Product A", 2.95m, "")); controller.OrderToLoad = order; controller.StartLoadOrderFlow(order.OrderId); presenter.OnViewInitialized(); Assert.AreEqual(1, view.OrderItemsLines.Count); }
public void SaveAsDraft(Order order) { SaveAsDraftCalled = true; }
private Order GetPopulatedOrder() { Order order = new Order(); order.OrderId = 1; order.Approver = "11"; order.CustomerId = "100"; order.ShipAddress = "225 112th NE Street"; order.ShipCity = "Bellevue"; order.ShipRegion = "Washington"; order.ShipPostalCode = "98005"; order.Creator = "CurrentUser"; order.OrderStatus = (int)OrderStatusEnum.Draft; return order; }
public virtual void CreateNewOrder() { Order currentOrder = new Order(); currentOrder.Creator = this.CurrentEmployee; currentOrder.OrderStatus = (int)OrderStatusEnum.Draft; CurrentOrder = currentOrder; }
private Order GetPopulatedOrder() { Order order = new Order(); order.OrderId = 1; order.Approver = "11"; order.CustomerId = "100"; order.ShipAddress = "225 112th NE Street"; order.ShipCity = "Bellevue"; order.ShipRegion = "Washington"; order.ShipPostalCode = "98005"; order.OrderName = "ORDER1"; order.Description = "Needs it quick"; return order; }
public void SaveAsDraft(Order order) { Guard.ArgumentNotNull(order, "order"); if (order.OrderStatus > (int)OrderStatusEnum.Draft) throw new InvalidOperationException(Resources.OrderStatusInvalidForSaveAsDraft); int newStatus = (int)OrderStatusEnum.Draft; order.OrderId = PersistOrder(order, newStatus); order.OrderStatus = newStatus; }
public void OnEditOrderUseOrdersControllerToLoadOrder() { httpContextLocatorService.MockHttpContext.User = new GenericPrincipal(new GenericIdentity("empl1"), null); ordersService.GetSavedDraftOrdersList = new List<Order>(); ordersService.GetSavedDraftOrdersList.Add(new Order(1, "name1", "cust1", "empl1", "desc1", (int)OrderStatusEnum.Submitted, null, null, null, null, null, null, null)); ordersService.GetSavedDraftOrdersList.Add(new Order(2, "name2", "cust2", "empl1", "desc2", (int)OrderStatusEnum.Submitted, null, null, null, null, null, null, null)); Order orderWithDetails = new Order(3, "name3", "cust3", "empl1", "desc3", (int)OrderStatusEnum.Submitted, null, null, null, null, null, null, null); orderWithDetails.Details.Add(new OrderDetail(3, 1, 2, 2.25m)); ordersService.GetSavedDraftOrdersList.Add(orderWithDetails); presenter.OnViewInitialized(); presenter.OnEditOrder("2"); Assert.IsTrue(ordersController.StartLoadOrderFlowCalled); Assert.AreEqual(2, ordersController.LoadedOrderId); }
public void SubmitOrder(Order order) { if (order.OrderStatus > (int)OrderStatusEnum.Draft) throw new InvalidOperationException(Resources.OrderStatusInvalidForSubmitOrder); int newStatus = (int)OrderStatusEnum.Submitted; order.OrderDate = DateTime.Now; order.OrderId = PersistOrder(order, newStatus); order.OrderStatus = newStatus; }
public void ShowOrderDetails(Order order) { ShowOrderDetailsCalled = true; OrderShown = order; }
private static void TranslateFromOrderEntityToOrdersRow(Order order, OrdersManagementDataSet.OrdersRow ordersRow) { ordersRow.CustomerId = order.CustomerId; ordersRow.Description = order.Description; ordersRow.Approver = order.Approver; ordersRow.Creator = order.Creator; ordersRow.OrderName = order.OrderName; ordersRow.OrderStatus = order.OrderStatus; ordersRow.ShipAddress = order.ShipAddress; ordersRow.ShipCity = order.ShipCity; ordersRow.ShipPostalCode = order.ShipPostalCode; ordersRow.ShipRegion = order.ShipRegion; }
public void ShowOrder(Order order) { ShowOrderInfoCalled = true; }
private static void TranslateFromOrdersRowToOrderEntity(OrdersManagementDataSet.OrdersRow ordersRow, Order order) { order.OrderId = ordersRow.OrderId; order.CustomerId = ordersRow.IsCustomerIdNull() ? null : ordersRow.CustomerId; order.Description = ordersRow.IsDescriptionNull() ? null : ordersRow.Description; order.Approver = ordersRow.Approver; order.Creator = ordersRow.Creator; order.OrderName = ordersRow.IsOrderNameNull() ? null : ordersRow.OrderName; order.OrderStatus = ordersRow.OrderStatus; order.ShipAddress = ordersRow.IsShipAddressNull() ? null : ordersRow.ShipAddress; order.ShipCity = ordersRow.IsShipCityNull() ? null : ordersRow.ShipCity; order.ShipPostalCode = ordersRow.IsShipPostalCodeNull() ? null : ordersRow.ShipPostalCode; order.ShipRegion = ordersRow.IsShipRegionNull() ? null : ordersRow.ShipRegion; }
public void ShowOrder(Order order) { ShowOrderCalled = true; OrderShown = order; }
public void SaveAsDraftCanStoreOrderWithoutDetailsInRepository() { Order order = new Order(); order.OrderId = 0; order.Approver = "11"; order.Creator = "11"; order.Details = null; OrdersManagementDataSet ds = new OrdersManagementDataSet(); OrdersService ordersService = new OrdersService(ds, new FakeProductService()); ordersService.SaveAsDraft(order); OrdersManagementDataSet.OrdersRow row = ds.Orders.FindByOrderId(order.OrderId); Assert.IsNotNull(row); Assert.AreEqual(1, ds.Orders.Count); }