How to test that action uses argument?
- by Caster Troy
I am supposed to be using test-driven development but in this particular case, as I am having trouble, I implemented the action method first. It looks like this:
public ViewResult Index(int pageNumber = 1)
{
var posts = repository.All();
var model = new PagedList<Post>(posts, pageNumber, PageSize);
return View(model);
}
Both the repository and the PagedList<> have been tested already. Now I want to verify that when the action is given a page number that the page number is actually considered.
private Mock<IPostsRepository> repository;
private HomeController controller;
[Test]
public void Index_Doohickey()
{
var actual = controller.Index(2);
// .. How do I test that the controller actually uses the page number here?
}