private void OnResrvedProductPurchased(ReservedProductPurchased evt)
        {
            var product = GetProduct(evt);

            product.Reserved       -= evt.Quantity;
            product.Quantity       -= evt.Quantity;
            product.LastEventNumber = evt.Metadata.EventNumber;
            _ctx.SaveChanges();
        }
        public void When_PurchaseReserveProduct_NewProductHasNewQuantity()
        {
            Given(InitialEvents);

            var command = new PurchaseReservedProduct(id, 3);

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

            When(command);

            var expectedEvent = new ReservedProductPurchased(id, 3);

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

            Then(expectedEvent);
        }
示例#3
0
 private void Apply(ReservedProductPurchased obj)
 {
     Quantity -= obj.Quantity;
     Reserved -= obj.Quantity;
 }