Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET MVC 1.0 Test Driven Development Problem - Design - Solution
This is the forum to discuss the Wrox book ASP.NET MVC 1.0 Test Driven Development Problem - Design - Solution by Emad Ibrahim ISBN: 978-0-470-44762-8
Welcome to the p2p.wrox.com Forums.

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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 30th, 2009, 06:36 PM
Registered User
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default Erratta for AccountControllerTests

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:

Code:
Assert.AreEqual("Index", typedResults.RouteValues["action"], "Wrong action");
Assert.AreEqual("Home", typedResults.RouteValues["controller"], "Wrong controller");
Hope this helps anyone else who might run into this issue.
Reply With Quote
The Following User Says Thank You to obiwaynekenobi For This Useful Post:
johnhilts (January 30th, 2010)
  #2 (permalink)  
Old January 30th, 2010, 03:44 PM
Registered User
 
Join Date: Jan 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default NInject from Unit Tests

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 . . .
Reply With Quote
  #3 (permalink)  
Old February 1st, 2010, 01:40 AM
Registered User
 
Join Date: Jan 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Undefined Code Assert.Item on p 136

On p 136 Undefined Code "Assert.Item" suddenly appears.

It can retrieved from the code download.
Reply With Quote
  #4 (permalink)  
Old February 1st, 2010, 02:26 AM
Registered User
 
Join Date: Jan 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Sort Links don't work P. 135

The sort links on p.135 seem to use an old version of the Html.ActionLink API.

Tried to fix it, but don't know what the correct syntax would be.

Got it to compile, but clicking link results in NInject error.

Here's the link I tried:
Code:
<th>
<%=Html.ActionLink("Name",  ViewData.GetSortDirection("name"), ((PagedList<Contact>)ViewData.Model).PageNumber.ToString())
%>
</th>
Reply With Quote
  #5 (permalink)  
Old February 28th, 2010, 11:21 AM
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down p36 AccountControllerTest -> AccountControllerTests

On page 36:

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'
Reply With Quote
  #6 (permalink)  
Old February 28th, 2010, 11:22 AM
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

Quote:
Originally Posted by obiwaynekenobi View Post
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:

Code:
Assert.AreEqual("Index", typedResults.RouteValues["action"], "Wrong action");
Assert.AreEqual("Home", typedResults.RouteValues["controller"], "Wrong controller");
Hope this helps anyone else who might run into this issue.
Great catch, mate!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 03:06 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.