public void GivenIHavePlacedAnOrderForASmallLatteWholeMilk() { var latteId = EventSourceHelper.GetId<Item>("Latte"); var orderId = Guid.NewGuid(); var e = new OrderPlaced( orderId, DiningLocation.TakeAway, new OrderItem[1] { new OrderItem( latteId, new Dictionary<string, string>() { {"Size", "small"}, {"Milk", "whole"} }, 1) }, 7.60M); GivenHelper.Given(orderId, e); }
public Order( Guid orderId, DiningLocation diningLocation, OrderItem[] orderItems, IProductInfo[] products) : this() { var price = orderItems .Select(i => new { product = products.Single(p => p.MenuItemId == i.MenuItemId), item = i }) .Select(i => i.item.Quantity*i.product.Price) .Sum(); var e = new OrderPlaced( orderId, diningLocation, orderItems, price); ApplyChange(e); }
private void Apply(OrderPlaced e) { Id = e.OrderId; _state = OrderState.Placed; _items.AddRange(e.OrderItems); _price = e.Price; _location = e.DiningLocation; }