public void OrdersCanBeCreated() { var expected = new Order(); var sut = new OrderService(); var actual = sut.PlaceOrder(expected); actual.Id.Should().BeGreaterThan(0); }
public Order PlaceOrder(Order order) { // TODO DAL/Webservice. Just fake that here var newOrder = new Order(); newOrder.Id = 1; newOrder.OrderDate = DateTime.Now; newOrder.DelieveryDate = newOrder.OrderDate.AddDays(2); newOrder.TrackingNumber = "1Z9999999999999999"; if (order.OrderItems != null) { int i=1; foreach (var orderItem in order.OrderItems) { var newOrderItem = new OrderItem(orderItem.ProductName) { Quantity = orderItem.Quantity }; newOrderItem.Id = i++; newOrderItem.TotalCost = GetTotalCost(GetProductCost(orderItem.ProductName), orderItem.Quantity); newOrder.OrderItems.Add(newOrderItem); } } return newOrder; }