I\'m writing a unit test and I call an action method like this
var result = controller.Action(123);
result is ActionResult
and
It's somewhat cheating but a very trivial way to do so in .NET4
dynamic result = controller.Action(123);
result.Model
Used this today in a unit test. Might be worth some sanity checks such as:
Assert.IsType(result);
Assert.IsType(result.Model);
Assert.Equal(123, result.Model.Id);
You could skip the first one if the result is going to be a view or partial result depending on the input.