We have the following lines in one of the functions in the MVC controller.
public ActionResult EditEmp(int eId = 0)
{
EPermission ePermission = (EPermission)HttpContext.Items["empPermission"];
}
In my unit test, I am calling this controller to test.
public void TestMethod1()
{
var result = eController.EditEmp(10) as ViewResult;
}
My test case fails because there is no value in the HttpContext
for empPermission
during the runtime.
We are wondering how can we populate the HttpContext.Items
with a value so it can pick up during the runtime. We have look for some examples in mock, but not any luck so far.