public void GetProductById_should_return_product_from_repository()
        {
            // arrange
            const int productId = 1;
            var mock = new Mock<IProductRepository>();

            var expected = new Product();

            mock.Setup(r => r.Get(productId)).Returns(expected);

            var controller = new ProductsController(mock.Object);

            // act
            var result = controller.GetProductById(1);

            // assert
            Assert.Equal(expected, result);
        }
 public bool Update(Product item)
 {
     int index = _products.FindIndex(p => p.Id == item.Id);
     if (index == -1)
     {
         return false;
     }
     _products.RemoveAt(index);
     _products.Add(item);
     return true;
 }
 public Product Add(Product item)
 {
     item.Id = _nextId++;
     _products.Add(item);
     return item;
 }