public void About() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.About() as ViewResult; // Assert Assert.AreEqual("Your application description page.", result.ViewBag.Message); }
public void Contact() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Contact() as ViewResult; // Assert Assert.IsNotNull(result); }
//Method to get the HomeController Object. Unit Tests will call methods in the HomeController private static HomeController GetHomeController(IStudentRepository repository) { HomeController controller = new HomeController(repository); controller.ControllerContext = new ControllerContext() { Controller = controller, RequestContext = new RequestContext(new MockHttpContext(), new RouteData()) }; return controller; }