public void GetProducts_WhenCalled_ReturnsProduct() { // Arrange const int id = 1; Product product = new Product { Id = 1, Name = "TestProduct" }; IProductService fakeProductService = Substitute.For<IProductService>(); IProductReviewService fakeProductReviewService = Substitute.For<IProductReviewService>(); fakeProductService.FindProduct(id).Returns(product); //Act ProductsController productsController = new ProductsController(fakeProductService, fakeProductReviewService); ProductVM result = productsController.Get(id); //Assert Assert.IsNotNull(result); }
private static List<ProductDetailVM> GetProductDetails(Product product) { return product.ProductDetails.Select(pd => new ProductDetailVM { Name = pd.Name, Content = pd.Content }).ToList(); }