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)); }
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)); }
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); }
private void Apply(BasketCancelled evt) { State = BasketState.Cancelled; }