Exemplo n.º 1
0
        public void WhenSupplierRequestsDifferentQuantity_ShouldCreateBookOrderLineConflict()
        {
            var sut = CreateSut();

            BookOrder bookOrder = BookOrder.CreateNew(
                "SupplierBar",
                Guid.NewGuid());

            bookOrder.AddBookRequest(
                a.BookTitleOrder
                .ForSupplier("SupplierBar")
                .ForTitle("The Hobbit")
                .WithPrice(20)
                .WithQuantity(10)
                );

            _bookOrderRepository.Store(bookOrder);

            var supplierBookOrderUpdateRequest = new SupplierBookOrderUpdateRequest(
                bookOrder.Id,
                new List <SupplierBookOrderLineUpdateRequest>()
            {
                new SupplierBookOrderLineUpdateRequest(
                    bookOrder.OrderLines[0].Id,
                    price: 20, quantity: 9)
            });

            sut.Execute(supplierBookOrderUpdateRequest);

            List <BookOrderLineConflict> conflicts =
                _bookOrderLineConflictRepository.GetForBookOrder(bookOrder.Id).ToList();

            conflicts.Count().Should().Be(1);
            conflicts[0].ConflictType.Should().Be(ConflictType.Quantity);
        }
Exemplo n.º 2
0
        private BookOrder StoreBookOrderWithOrderLineForSupplier(string supplier)
        {
            BookOrder bookOrder = BookOrder.CreateNew(
                "SupplierBar",
                Guid.NewGuid());

            bookOrder.AddBookRequest(
                a.BookTitleOrder
                .ForSupplier(supplier)
                .ForTitle("The Hobbit")
                );
            _bookOrderRepository.Store(bookOrder);

            return(bookOrder);
        }