I am new to unit testing and trying to learn TDD, but I cannot figure out how to test this. I spent two days on it already (don't worry it is not for an employer, so please no smart answers).
I wrote a controller that I want to test, I need to assign a value to "Choice". Simplified, it looks like this:
public ActionResult Index()
{
string s = Request["Choice"];
return View(new MyList.GetList(s));
}
How do I assign a value to "Choice" in the test or can I? In the application, the value of "Choice" is assigned by a radiobutton in a form in the page view. This is my test in psuedocode:
[TestMethod()]
public void IndexTest()
{
CategoryController target = new CategoryController();
var result = target.Index() as ViewResult;
MyList actual = result.ViewData.Model as MyList;
// etc ...
Assert.AreEqual(expected.List, actual.List);
}
Thanks, Mario