Esempio n. 1
0
        internal void CancelReservation(CancelProductReservation cmd)
        {
            var productId = cmd.AggregateId;
            var quantity  = cmd.Quantity;

            if (quantity > Reserved)
            {
                quantity = Reserved;
            }
            RaiseEvent(new ProductReservationCancelled(productId, quantity));
        }
Esempio n. 2
0
        public void When_CancelProductReservationLessThanReserved_ProductReservationCanceled()
        {
            Given(InitialEvents);

            var command = new CancelProductReservation(id, 10);

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

            When(command);

            var expectedEvent = new ProductReservationCancelled(id, 3);

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

            Then(expectedEvent);
        }