예제 #1
0
        public void OrderVerifiedRaisesOrderReadyEvent()
        {
            var product      = new OrderProduct(productId: 123, quantity: 1);
            var domainEvents = new SpyDomainEvents();
            var order        = new Order(orderId: 234, products: new[] { product })
            {
                DomainEvents =
                {
                    Instance = domainEvents
                }
            };

            order.Verify();

            order.State.Should().Be(OrderState.Ready);

            domainEvents.RaisedEvents.ShouldAllBeEquivalentTo(new OrderReadyEvent(orderId: 234));
        }
예제 #2
0
        public void OrderVerifiedAlreadyReadyDoesNotRaiseEvent()
        {
            var product      = new OrderProduct(productId: 123, quantity: 1);
            var domainEvents = new SpyDomainEvents();
            var order        = new Order(orderId: 234, products: new[] { product })
            {
                DomainEvents =
                {
                    Instance = domainEvents,
                }
            };

            order.Verify();
            domainEvents.Clear();

            order.Verify();

            domainEvents.RaisedEvents.Should().BeEmpty();

            StockQuantity quantity    = new StockQuantity(123);
            int           intQuantity = quantity;
        }