public void Info() { var mockStorage = new Mock<IStorage<Product>>(); Product p = new Product { ArticleNr = "1", Name = "name", Description = "desc" }; mockStorage.Setup(r => r.Get(It.IsAny<Request>())).Returns(p); var controller = new ProductController(new ProductService(mockStorage.Object), _mockPathUtilites.Object); ViewResult result = controller.Info("12345-21") as ViewResult; Assert.IsNotNull(result); var model = result.Model as ProductViewModel; Assert.AreEqual(p.ArticleNr, model.ArticleNr); }
public void Index() { var mockStorage = new Mock<IStorage<Product>>(); Product p = new Product { ArticleNr = "1", Name = "name", Description = "desc" }; mockStorage.Setup(r => r.GetList(null)).Returns(new List<Product> { p }); var controller = new ProductController(new ProductService(mockStorage.Object), _mockPathUtilites.Object); ViewResult result = controller.Index() as ViewResult; Assert.IsNotNull(result); var model = result.Model as ProductListingViewModel; Assert.IsTrue(model.Products.Any()); }