public void When_AddItemNotPending_ThrowsInvalidStateException(string checkedOutOrCancelled)
        {
            IEvent evt = new BasketCheckedOut(id, new List <OrderLine>(), new Address());

            if (checkedOutOrCancelled == "cancelled")
            {
                evt = new BasketCancelled(id);
            }

            InitialEvents.Add(evt);

            Given(InitialEvents.ToArray());

            WhenThrows <AddItemToBasket, InvalidStateException>(new AddItemToBasket(id, productId, "Test Product", 2, 10));
        }
예제 #2
0
        public void When_RemoveItemNotPending_ThrowsInvalidStateException(string checkedOutOrCancelled)
        {
            IEvent evt = new BasketCheckedOut(id, OrderLines, new Address());

            if (checkedOutOrCancelled == "cancelled")
            {
                evt = new BasketCancelled(id);
            }

            InitialEvents.Add(evt);

            Given(InitialEvents.ToArray());

            WhenThrows <RemoveItemFromBasket, InvalidStateException>(new RemoveItemFromBasket(id, productId, 10));
        }
예제 #3
0
        public void When_Cancel_Cancelled()
        {
            Given(InitialEvents);

            var command = new CancelBasket(id);

            command.Metadata.CausationId   = command.Metadata.CommandId;
            command.Metadata.CorrelationId = causationAndCorrelationId;

            When(command);

            var expectedEvent = new BasketCancelled(id);

            expectedEvent.Metadata.CausationId   = command.Metadata.CommandId;
            expectedEvent.Metadata.CorrelationId = causationAndCorrelationId;
            expectedEvent.Metadata.ProcessId     = command.Metadata.ProcessId;

            Then(expectedEvent);
        }
예제 #4
0
 private void Apply(BasketCancelled evt)
 {
     State = BasketState.Cancelled;
 }