public void valid_adjust_products_stock()
        {
            // setp
            customerRepository
            .Setup(cr => cr.GetById(1))
            .Returns(CustomerMother.Random());

            productRepository
            .Setup(pr => pr.GetById(1))
            .Returns(ProductMother.StandardProductWith1000Stock());

            var productsUpdates = new List <Product>();

            productRepository
            .Setup(pr => pr.Update(It.IsAny <IEnumerable <Product> >()))
            .Callback <IEnumerable <Product> >(products =>
            {
                productsUpdates.AddRange(products);
            });

            var products = new List <ProductInputModel>()
            {
                new ProductInputModel()
                {
                    ProductId = 1,
                    Quantity  = new QuantityValue(10, "UM"),
                }
            };

            // act
            var invoice = createManager.Create(
                date: DateTime.Now,
                expirationDate: DateTime.Now.AddDays(2),
                totalReceived: new MonetaryValue(100, "CO"),
                customerId: 1,
                productInputs: products);

            // val
            foreach (var item in invoice.Items)
            {
                var stockExpected = new QuantityValue(
                    ProductMother.StandardProductWith1000Stock().StockQuantity.Value - item.Quantity.Value, "UM");

                var product = productsUpdates.FirstOrDefault(p => p.Id == item.ProductId);

                product
                .Should()
                .NotBeNull();

                product
                .StockQuantity
                .Should()
                .Be(stockExpected);
            }
        }
        public void valid_insert_invoice()
        {
            // setp
            var products = new List <ProductInputModel>()
            {
                new ProductInputModel()
                {
                    ProductId = 1,
                    Quantity  = new QuantityValue(1, "UM"),
                }
            };

            customerRepository
            .Setup(cr => cr.GetById(1))
            .Returns(CustomerMother.Random())
            .Verifiable();

            productRepository
            .Setup(pr => pr.GetById(It.IsAny <int>()))
            .Returns(ProductMother.StandardProductWith1000Stock())
            .Verifiable();

            // act
            createManager.Create(
                date: DateTime.Now,
                expirationDate: DateTime.Now.AddDays(2),
                totalReceived: new MonetaryValue(100, "CO"),
                customerId: 1,
                productInputs: products)

            // valitation
            .Should().As <InvoiceViewModel>();

            productRepository.Verify();
            productRepository.Verify();
            productRepository.Verify(pr => pr.Update(It.IsAny <IEnumerable <Product> >()), Times.AtLeastOnce);
            invoiceRepository.Verify(re => re.Insert(It.IsAny <Invoice>()), Times.AtLeastOnce);
        }