Hello!!
Please help me how to nunit test. I have a method in the controller and i want to unit test it with the concept of mocking.
Can anyone guide me through on Nunit testing?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ranjeet PatraPosted Mar 30, 2017, 7:57 AM
public void About()
{
// Arrange
HomeController controller = new HomeController();
// Act
bool val = controller.About();
// Assert
Assert.IsTrue(val);
}
Rohanjoy BhattacharyaPosted Mar 30, 2017, 7:23 AM
Ranjeet PatraPosted Mar 30, 2017, 6:43 AM
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public void About()
{
// Arrange
HomeController controller = new HomeController();
// Act
ViewResult result = controller.About() as ViewResult;
// Assert
Assert.AreEqual("Your application description page.", result.ViewBag.Message);
}
Rohanjoy BhattacharyaPosted Mar 30, 2017, 5:50 AM
Ranjeet PatraPosted Mar 30, 2017, 4:25 AM