Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 private void Apply(OrderPaid e)
 {
     _state = OrderState.Paid;
 }
Esempio n. 3
0
        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);
        }