First Test Crashes using MSTEST with ASP.NET MVC 1
- by Trey Carroll
I'm trying to start using Unit Testing and I want to test the following Controller:
public class AjaxController : Controller
{
...
public JsonResult RateVideo( int userRating, long videoId )
{
string userName = User.Identity.Name;
...
}
}
I have a created a TestClass with the following method:
[ TestMethod
public void TestRateVideo()
{
//Arrange
AjaxController c = new AjaxController();
//Act
JsonResult jr = c.RateVideo(1, 1);
//Assert
//Not implemented yet
}
I select debug and run the test. When the code reaches the 1st statement:
string username = User.Identity.Name;
Debugging stops and I am presented with a message that says that the test failed.
Any guidance you can offer would be appreciated.