public void Index() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.AreEqual("Welcome to ASP.NET MVC!", result.ViewBag.Message); }
public void Index_Should_Return_All_Products_In_DB() { //Arrange this.MockRepository.Setup(foo => foo.GetAll()).Returns(this.Products.Take(2).ToList()); //Act HomeController controller = new HomeController(this.MockRepository.Object); var viewResult = controller.Index() as ViewResult;; var model = viewResult.ViewData.Model as List<Product>; //Assert model.Count.ShouldBe(2); }