Exemple #1
0
        public void Handle_PurchaseBookCommand_Default()
        {
            // arrange
            var key = MockBuilder.Key;

            var command = PurchaseBookCommandMock.Get(key);

            // act
            var result = Handle(command);

            // assert
            result.Should().BeTrue();

            var orders = MockRepository.Query <Order>()
                         .Include(x => x.Items)
                         .Include(x => x.Customer)
                         .ToList();
            var orderExpected = OrderMock.Get(key);

            orders.Should().BeEquivalentToEntity(MockBuilder.List(orderExpected));

            var publishShippingEventCommands        = Bus.GetAllSent <PublishShippingEventCommand>(ContextNames.Queue.Bookstore);
            var publishShippingEventCommandExpected = PublishShippingEventCommandMock.Get(key);

            publishShippingEventCommandExpected.OrderId = orders[0].Id;
            publishShippingEventCommands.Should().BeEquivalentToMessage(MockBuilder.List(publishShippingEventCommandExpected));

            var dropCopyNumberEvents        = Bus.GetAllPublished <DropCopyNumberEvent>(ContextNames.Exchange.Bookstore);
            var dropCopyNumberEventExpected = DropCopyNumberEventMock.Get(key);

            dropCopyNumberEvents.Should().BeEquivalentToMessage(MockBuilder.List(dropCopyNumberEventExpected));
        }
Exemple #2
0
        public void Handle_PurchaseBookCommand_Customer_Not_Exists()
        {
            // arrange
            var key = MockBuilder.Key;

            var command = PurchaseBookCommandMock.Get(key);

            // act
            var result = Handle(command);

            // assert
            result.Should().BeTrue();

            var customers        = MockRepository.Query <Customer>().ToList();
            var customerExpected = CustomerMock.Get(key);

            customers.Should().BeEquivalentToEntity(MockBuilder.List(customerExpected));

            var orders = MockRepository.Query <Order>()
                         .Include(x => x.Items)
                         .Include(x => x.Customer)
                         .ToList();
            var orderExpected = OrderMock.Get(key);

            orderExpected.Customer = customerExpected;
            orders.Should().BeEquivalentToEntity(MockBuilder.List(orderExpected));
        }