Exemplo n.º 1
0
        public void valid_update_product()
        {
            // setp
            var product = ProductMother.MartilloProductWithStock();

            repository
            .Setup(rp => rp.GetById(It.IsAny <int>()))
            .Returns(product);

            repository
            .Setup(rp => rp.Update(It.IsAny <Product>()))
            .Verifiable();

            // act
            updateManager.Update(product.Id);

            // val
            repository.Verify();
        }
        public IActionResult Put(
            int productId, ProductRequest productRequest)
        {
            try
            {
                var product = updateManager.Update(
                    productId,
                    productRequest.Description,
                    productRequest.Name,
                    productRequest.FriendlyName,
                    productRequest.Price,
                    productRequest.Tax,
                    productRequest.TaxDescription);

                return(Ok(product));
            }
            catch (ProductNotFound)
            {
                return(NotFound());
            }
        }