22 July 2013

Cheats : Commonly-Used Asserts

This is not a tutorial. I provide this short cheat simply for my team that develops small "Kampung Project" in MVC.

Here are the commonly-used Asserts we use in Unit Test using NUnit. I will update this info soon.

Assert.IsInstanceOf <ViewResult> (results);
Assert.IsInstanceOf <RedirectToRouteResult> (results);
Assert.IsInstanceOf <List<KampungName>> (results);
Assert.AreEqual (2, results);
Assert.AreEqual (3, results.count);
Assert.AreEqual ("Create", results.ViewName);
Assert.AreEqual ("Index", results.RouteValues["action"]);
Assert.AreEqual("Home", results.RouteValues["controller"]);
Assert.IsNotNull (results);
Assert.IsTrue(controller.ModelState.IsValid);


No comments:

Post a Comment