The topic says it all.
I'm guessing this is because of some missing setup related to MVC, but I'm very new to the world of http, asp.net and mvc, so I'm not quite sure what's wrong.
public class MyController : Controller {
public ActionResult MyAction(MyModel model) {
return View(model);
}
}
var controllerMock = new Mock<MyController>() {
CallBase = true // without this, the call to View(model) returns null
};
/*
* I've also tried this before calling the action:
*
* controllerMock.SetFakeControllerContext();
*
* from http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx
* But the same applies.
**/
ViewResult result = controllerMock.Object.MyAction(new MyModel()) as ViewResult;
Assert.AreEqual("MyAction", result.ViewName); // ViewName etc is blank