Blog

Posts by Jonathan McCracken

08 Sep 2010, 13:30
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > GetOrganised Test Class Can't access Controllers)

You’ll need to add a reference to your Web project in your Unit.Test project. Just right click under References and select the “Project” tab and you’ll see it listed.

Another possibility is that your controller class isn’t public, so make sure that your controller looks like:

public class TodoController : Controller

With regards to the @using@ statements you’ll notice that they’re not always included in the book text. I did this intentionally to save space in the book. If you’re using Visual Studio without Resharper you can right-click on the code that’s causing a compiler error and select “Resolve”. That will give you an option to add the missing using statement automatically.

Hope that helps,

Jonathan

09 Sep 2010, 21:04
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > get an error on Route testing)

Vishal,

Check out the reply to a similar post.

The way it’s stated in the book is incorrect (it’s being fixed for the next printing) - you’ll need to follow the proper instructions in the above post.

Hope that helps,

Jonathan

13 Sep 2010, 14:55
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > Gettinh error testing Should_Create_Topic_And_Notify_The_User)

Juan,

Try a couple things. First make sure that Equals() is working properly for your Topic object. You can add a break-point to the Equals() method in Topic when debugging the test to see what is not equal or where your equals method is causing the problem. If that doesn’t fix it try this:

Verify that you are clearing the Topic.Topics collection in every test. You can do that by adding the following to your setup fixture:

[Setup]
public void setup()
{
Topic.Topics = Topics = new List<Topic>
              {
               new Topic {Id = 1, Color = Color.Red, Name = "Work"},
               new Topic {Id = 2, Color = Color.Blue, Name = "Home"}
              };
}

This will make sure that your Topic.Topics collection is reset every time you run the test and the static list isn’t becoming a side effect.

Hope that helps,

Jonathan

29 Sep 2010, 15:24
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > Version 1.1 of Book is Available!)

Hi everyone,

I just wanted to post a big thank you to several readers who helped with the 1.1 of PDF. David Jenkins (who’s posted more to this forum than I have!), Greg Heath, Alexander DiMauri, John CrankShaw,Robert Dzikowski, Dave Mateer.

Thanks to yours and others feedback the new version now has a downloadable Visual Studio solution file per chapter under /code/chapter_name/solution to let you check your answers against mine.

Now onto MVC 3.0 changes… :)

Regards,

Jonathan

10 Oct 2010, 12:02
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > Jumping in book / TodoController)

Mike,

Makes sense - at that point in the book the testing routes section wouldn’t have been completed so that part of the code will look foreign until you get to the end of the chapter. I’ll make a note to change the text in the next revision - either to provide the solution in the text or qualify what you’ll see in the chapter’s solution folder.

Thanks,

Jonathan

18 Nov 2010, 13:59
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > Okay to post code to github?)

Sharon,

I think it would be fine if you posted the code there - just to be sure I’ll double check with my editor. If you do post the code to git-hub it might be helpful for you to share the link in this forum so others can benefit from your learning.

Glad you’re enjoying the book,

Jonathan

18 Nov 2010, 14:03
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > AssertionException on Should_Route_To_Edit_Page_With_Title)

Robert - yeah it’s unfortunate that MvcContrib doesn’t handle query strings. I think their reasoning is that MVC’s model binding mechanism is what should be used to handle that.

From a testing point of view that would separate these kinds of scenarios so your binding is tested via a custom or generic model binder, while the route is tested via the above helper method.

Thanks,

Jonathan

20 Nov 2010, 01:35
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > Okay to post code to github?)

Sharon,

I think it’s fine - so long as you follow these instructions:

“the code all has comments as to where it came from, right? In that case let them use it, but yes, provide a link and an explanation.”

Jonathan

26 Nov 2010, 20:30
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > Namespace issues)

Joel,

Yeah the namespaces can be a bit inconsistent, but I’ve tried to clean them up in the downloadable code. If you’re just using Visual Studio you can right-click and select “Resolve” to fix them. Otherwise, if you have Resharper installed you can fix them by hitting ALT+ENTER.

Hope that helps,

Jonathan

30 Nov 2010, 16:08
Headshot_pragsmall

Jonathan McCracken (35 posts)

(from Test-Drive ASP.NET MVC > Reconciling dependencies within 3rd-party DLLs)

John,

Yes this is a bit of dependency nightmare… I’ve actually posted the DLLs you need here on my blog:

http://jonathanmccracken.blogspot.com/2010/08/windsor-20-and-log4net.html

The problem lies in a version mis-match of Castle Dynamic Proxy is incompatible with FluentNHibernate and Castle Windsor. So to solve the problem I just compiled the assemblies myself.

I haven’t checked lately if FluentNHibernate is now using a more modern version of Castle Dynamic Proxy, but if they are that might also solve the problem.

Hope that helps,

Jonathan

35 posts