public void When_SomeProductReservationFailed_NotifyAdmin() { var notificationId = Guid.NewGuid(); AggregateRepository.CreateGuid = () => notificationId; SetupPreviousEvents(); orderId = AddProcessedEvent <BasketAggregate>(new BasketCheckedOut(basketId, OrderLines, shippingAddress)); AddProcessedEvent <OrderAggregate>(new OrderCreated(orderId, basketId, shippingAddress), orderId); AddProcessedEvent <ProductAggregate>(new ProductReserved(productOneId, 10), orderId); var evt = new ProductReservationFailed(productOneId, 20, ProductReservationFailed.NotAvailable); AddPreviousEvent <ProductAggregate>(evt); SetInitalMetadata(); Given(_initialEvents.ToArray()); WhenProcessed(evt); var expectedCommands = new List <ICommand> { new NotifyAdmin(notificationId) }; var expectedEvents = new List <IEvent> { new EventProcessed(orderId, evt) }; SetMetadata(evt, expectedCommands, expectedEvents); Then(expectedCommands.ToArray()); Then(expectedEvents.ToArray()); }
public void When_ReserveProductLessThanAvailable_ThrowQuantityChangeException() { Given(InitialEvents); var command = new ReserveProduct(id, 10); command.Metadata.CausationId = command.Metadata.CommandId; command.Metadata.CorrelationId = causationAndCorrelationId; When(command); var expectedEvent = new ProductReservationFailed(id, 10, ProductReservationFailed.NotAvailable); expectedEvent.Metadata.CausationId = command.Metadata.CommandId; expectedEvent.Metadata.CorrelationId = causationAndCorrelationId; expectedEvent.Metadata.ProcessId = command.Metadata.ProcessId; Then(expectedEvent); }
private void Apply(ProductReservationFailed obj) { DispatchCommand <DummyNotifier>(new NotifyAdmin(AggregateRepository.CreateGuid())); }
private void OnProductReservationFailed(ProductReservationFailed evt) { _orderProcessEventHandler.HandleEvent <ProductReservationFailed, OrderProcessManager>(evt); SetLastEventNumber(evt); }