public void When_AddItem_BasketAddItemAdded() { Given(InitialEvents.ToArray()); var command = new AddItemToBasket(id, productId, "Test Item", 2, 10); command.Metadata.CausationId = command.Metadata.CommandId; command.Metadata.CorrelationId = causationAndCorrelationId; When(command); var expectedEvent = new BasketItemAdded(id, productId, "Test Item", 2, 10); expectedEvent.Metadata.CausationId = command.Metadata.CommandId; expectedEvent.Metadata.CorrelationId = causationAndCorrelationId; expectedEvent.Metadata.ProcessId = command.Metadata.ProcessId; Then(expectedEvent); }
private void AddProductToOrderLines(BasketItemAdded evt) { var productId = evt.ProductId; var productName = evt.ProductName; var price = evt.Price; var quantity = evt.Quantity; var orderLine = OrderLines.SingleOrDefault(ol => ol.ProductId == productId); if (orderLine == null) { orderLine = new OrderLine { ProductId = productId, ProductName = productName, Price = price, Quantity = quantity }; OrderLines.Add(orderLine); } else { orderLine.Quantity += quantity; } }
private void Apply(BasketItemAdded evt) { AddProductToOrderLines(evt); }