Пример #1
0
        public void AddToFavorites_IsAddedToFavorites(int id)
        {
            var product = new Product {
                ProductId = id, IsFavorite = false
            };
            var productRepositoryMock = new Mock <IProductRepository>();

            productRepositoryMock.Setup(repository => repository.GetProductById(id)).Returns(product);

            var sut = new FavoriteService(productRepositoryMock.Object);

            sut.AddToFavorites(product);

            product.IsFavorite.Should().BeTrue();
        }
Пример #2
0
        public void AddToFavorites_CallsUpdateProduct(int id)
        {
            var product = new Product {
                ProductId = id
            };
            var productRepositoryMock = new Mock <IProductRepository>();

            productRepositoryMock.Setup(repository => repository.GetProductById(id)).Returns(product);

            var sut = new FavoriteService(productRepositoryMock.Object);

            sut.AddToFavorites(product);

            productRepositoryMock.Verify(repository => repository.UpdateProduct(product));
        }