Inheritance: Controller
コード例 #1
0
        public void Index()
        {
            // Arrange
            HomeController controller = new HomeController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #2
0
        public void Index_Should_Return_To_The_View_A_List_Of_Products()
        {
            // Arrange
            var mockDataSvc = MockRepository
                .GenerateMock<IProductDataService>();
            mockDataSvc.Stub(m => m.GetProducts())
                .Return(new List<ProductViewModel>() { });
            var target = new HomeController(mockDataSvc);

            // Act
            var res = target.Index();

            // Assert
            Assert.IsInstanceOfType(res, typeof(ViewResult));
            var vr = res as ViewResult;
            Assert.IsInstanceOfType(vr.ViewData.Model, typeof(IndexViewModel));
        }