I have a little problem with UnitTests for asp.net mvc3 application.
If I run some unit-tests in Visual Studio 2010 Professional, they have been passed successfully.
If I use the Visual Studio 2010 Professional command line
mstest /testcontainer:MyDLL.dll /detail:errormessage /resultsfile:"D:\A Folder\res.trx"
Then the error occurred:
[errormessage] = Test method MyDLL.AController.IndexTest threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
and my controller:
public ActionResult Index(){
RedirectToAction("AnotherView");
}
and in the test
AController myController = new AController();
var result = (RedirectToRouteResult)myController.Index();
Assert.AreEqual("AnotherView", result.RouteValues["action"]);
How to solve this to work properly in both situations (VS2010 and mstest.exe) ?
Thank you
PS: I read Test run errors with MSTest in VS2010 but that could solve if I have VS2010 Ultimate/Premium.