First Test Crashes using MSTEST with ASP.NET MVC 1
Posted
by Trey Carroll
on Stack Overflow
See other posts from Stack Overflow
or by Trey Carroll
Published on 2010-03-18T01:40:15Z
Indexed on
2010/03/18
1:41 UTC
Read the original article
Hit count: 622
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.
© Stack Overflow or respective owner