I have a ArticleController that displays a list of articles according to a category.
public ActionResult List(string categoryname)
{
MyStronglyTypedViewData vd = new MyStronglyTypedViewData();
DBFactory factory = new DBFactory();
categoryDao = factory.GetCategoryDao();
articleDao = factory.GetArticleDao();
vd.Category = categoryDao.GetByName(categoryname);
vd.Articles = articleDao.GetByCategoryId(vd.Category.Id);
return View(vd);
}
If I was to unit test this action, what exactly would be the purpose?
TO make sure the correct view is being opened?
MyStronglyTypedViewDataThis line
DBFactory factory = new DBFactory();makes me think that it would be difficult to write a unit test because you don’t use an interface that could be mocked, but rather rely on a concrete class which might hit the actual database.