Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 private void Apply(OrderPlaced e)
 {
     Id = e.OrderId;
     _state = OrderState.Placed;
     _items.AddRange(e.OrderItems);
     _price = e.Price;
     _location = e.DiningLocation;
 }