MVC – Unit Tests – Form values

I wrote a unit test for an ActionResult method in a controller which has the following variable assignment from a form:

 model.ManagerId = Int32.Parse(Request.Form["Managers"].ToString()); 

"Managers" represents a Kendo DropDownList.

This line is throwing a NullReferenceException error. Is there any way to handle this from a unit test?


by nufsven via /r/csharp

Leave a Reply