コード例 #1
0
        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;
 }