Confirm that the controller exists
The presence of unit tests for its actions is a strong suggestion that the controller exists, which leads us to:
What would a unit test look like? Check the action Result from view
Here is an example:
public class HomeController: Controller { private readonly IRepository _repository; public HomeController(IRepository repository) { _repository = repository; } public ActionResult Index() { var customers = _repository.GetCustomers(); return View(customers); } }
And the corresponding unit test:
[Test] public void HomeController_Index_Action_Should_Fetch_Customers_From_Repo() {
MVCContrib has some great features that allow you to make fun of the HttpContext as well as check your routes .
Darin Dimitrov
source share