Beispiel #1
0
        public void When_RemoveProductFromStockZero_NothingHappens()
        {
            Given(
                new ProductCreated(id, "Test Product", 2),
                new ProductQuantityChanged(id, 5));

            var command = new RemoveProductFromStock(id, 0);

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

            When(command);

            Then(new IEvent[] { });
        }
Beispiel #2
0
        public void When_RemoveProductFromStock_ProductQuantityChanged()
        {
            Given(
                new ProductCreated(id, "Test Product", 5),
                new ProductQuantityChanged(id, 5));

            var command = new RemoveProductFromStock(id, 3);

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

            When(command);

            var expectedEvent = new ProductQuantityChanged(id, -3);

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

            Then(expectedEvent);
        }
Beispiel #3
0
        internal void RemoveFromStock(RemoveProductFromStock cmd)
        {
            var newQuantity = Quantity - cmd.Quantity;

            ChangeQuantity(newQuantity);
        }