Ejemplo n.º 1
0
        public void Products()
        {
            var mockService = new Mock <INorthwindService>();

            mockService.Setup(s => s.GetProducts(2)).Returns(getProducts());
            var mockConfiguration = new Mock <IConfiguration>();

            mockConfiguration.Setup(s => s["MaximumProducts"]).Returns("2");
            var mockLogger = new Mock <ILogger <HomeController> >();

            var controller = new HomeController(mockService.Object, mockConfiguration.Object, mockLogger.Object, null);

            var result = controller.Products() as ViewResult;
            var model  = result.ViewData.Model as List <Product>;


            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.IsInstanceOfType(result.Model, typeof(List <Product>));
            Assert.AreEqual(2, model.Count);
        }