public void OrderDispatchedEvent_should_work_with_default_sizes()
        {
            // create the event
            var order = new Order(345);
            order.Lines.Add(new OrderLine("Widget", "-", 2));
            var @event = new OrderDispatchedEvent(order);

            // create existing stock items
            var dateCreated = new DateTime(2011, 2, 15);
            var stockItems = new System.Collections.Generic.List<StockItem>()
            {
                StockItem.Create("Widget", "-", dateCreated, "*****@*****.**"),
            };

            // create some initial stock
            stockItems[0].ReceiveStock(10, dateCreated, user);
            stockItems[0].Deactivate(dateCreated, user);

            stockItemRepository.GetAllDelegate = () => stockItems.AsQueryable();

            // execute
            decrementStockLevelOnOrderDispatchedEvent.Handle(@event);

            // assert
            stockItems[0].Level.ShouldEqual(8); // 10-2 = 8
        }
        public OrderDispatchedEvent(Order order)
        {
            if (order == null)
            {
                throw new ArgumentNullException("order");
            }

            Order = order;
        }
        public void Handle(OrderDispatched orderDispatched)
        {
            if (orderDispatched == null)
            {
                throw new ArgumentNullException("orderDispatched");
            }

            var order = new EventOrder(orderDispatched.Order.Id);

            foreach (var orderLine in orderDispatched.Order.OrderLines)
            {
                order.Lines.Add(new EventOrderLine(orderLine.ProductUrlName, orderLine.SizeName, orderLine.Quantity));
            }

            var externalOrderDispatched = new OrderDispatchedEvent(order);

            domainEventService.Raise(externalOrderDispatched);
        }