Act Method
Now, we move on the Act section. In our testing environment, when we call the HomeController, it needs to be filled with our mock of repository.
// Act
HomeController controller = new HomeController(productRepository);
Unfortunately, we don't have the constructor of HomeController that takes productRepositoty input. So, just make it.
private Repository repository;
public HomeController(Repository repo)
{
repository = repo;
}
However, we must have an empty constructor of HomeController.
public HomeController()
{
repository = null;
}