public void GivenIHavePaidForTheOrder() { var orderId = EventSourceHelper.GetId<Order>(); var orderEvents = GivenHelper.GivenEvents(orderId).ToArray(); var orderPlacedEvent = orderEvents.OfType<OrderPlaced>().Single(); if (orderEvents.Last() != orderPlacedEvent) throw new NotSupportedException("Sorry. This test helper isn't set up to handle updated orders."); var e = new OrderPaid( orderId, orderPlacedEvent.DiningLocation, orderPlacedEvent.OrderItems, orderPlacedEvent.Price, "Jason Dentler", "5444444444444444", Guid.NewGuid(), Guid.NewGuid()); GivenHelper.Given(orderId, e); }
private void Apply(OrderPaid e) { _state = OrderState.Paid; }
public void Pay(string cardHolderName, string cardNumber) { switch (_state) { case OrderState.Cancelled: throw new InvalidStateException("You can't pay for this order. It is cancelled. Place a new order."); case OrderState.Paid: throw new InvalidStateException("You can't pay for this order. It's already paid."); } var e = new OrderPaid( Id, _location, _items.ToArray(), _price, cardHolderName, cardNumber, Guid.NewGuid(), Guid.NewGuid()); ApplyChange(e); }