You are currently viewing the BOOK: ASP.NET MVC 1.0 Test Driven Development Problem - Design - Solution section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
It looks like the book was written using a preview release of ASP.NET MVC, as I found the following issue:
Code:
var typedResults = results as RedirectToRouteResult;
Assert.AreEqual("Index",
typedResults.Values["action"],"Wrong action");
Assert.AreEqual("Home",
typedResults.Values["controller"],
"Wrong controller");
In the RC and 1.0 release of ASP.NET MVC the Views dictionary is changed to RouteViews so the code requires adding the assembly System.Web.Routing, and should be this instead:
I have noticed that NInject didn't work from Unit Tests until well into Chapter 8, when the IoC bindings were created in the Test Fixture Setup.
Before that, the book directs us to use NInject, but the tests would fail because the objects that were supposed to be injected were null references. To make the tests pass, you have to pass the mock object via the constructor or setter property, which you shouldn't have to do because the whole point of an IoC container is to do that for you. So I thought maybe there was some problem with NInject . . .
It's pretty clear that the neither the author nor the editor have actually worked through the book, or they would have seen this right away. The material covered is great, so we'll just need to fill in the gaps with the errata and hope for a better 2nd edition . . .
Before we can start cranking out tests, we need to create a test class. Let’s add a new test class for the
AccountController and name it AccountControllerTest. In order for it to be a test class, you deco-
rate it with MbUnit’s [TestFixture] attribute. Here is the class:
[TestFixture]
class AccountControllerTest
{
}
Then, there is a convention box, which clearly states test classes should be named plural (Tests).
Makes you kinda wonder if these books are reviewed before they are published...
P.S. Topic starter might as well re-name this topic to 'Errata'
It looks like the book was written using a preview release of ASP.NET MVC, as I found the following issue:
Code:
var typedResults = results as RedirectToRouteResult;
Assert.AreEqual("Index",
typedResults.Values["action"],"Wrong action");
Assert.AreEqual("Home",
typedResults.Values["controller"],
"Wrong controller");
In the RC and 1.0 release of ASP.NET MVC the Views dictionary is changed to RouteViews so the code requires adding the assembly System.Web.Routing, and should be this instead: