示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
 private void Apply(ProductReservationFailed obj)
 {
     DispatchCommand <DummyNotifier>(new NotifyAdmin(AggregateRepository.CreateGuid()));
 }
示例#4
0
 private void OnProductReservationFailed(ProductReservationFailed evt)
 {
     _orderProcessEventHandler.HandleEvent <ProductReservationFailed, OrderProcessManager>(evt);
     SetLastEventNumber(evt);
 }