In this tip, I discuss Eric Hexter’s TDD Class Generator Add-In for Visual Studio. This Add-In enables you to generate a class, an interface, and a test class by entering a single keyboard shortcut.
Eric Hexter — who has done valuable work on the MvcContrib project — visited Microsoft last week and showed me one of his current projects. He has started a project for building ASP.NET MVC specific Add-Ins for Visual Studio. In particular, he has created an Add-In for generating testable classes automatically.
You can learn more about the project, and download the binaries and source code, from the following website:
http://erichexter.googlecode.com/svn/trunk/TestFirstGenerator/
You also can view a quick video walk-through of the Add-In at:
http://erichexter.googlecode.com/svn/trunk/TestFirstGenerator/docs/ScreenCast.htm
Download the LatestVersion.zip file and unzip the archive. After unzipping the archive, make sure that you right-click the file, select Properties, and click the Unblock button (see Figure 1). If you forget to unblock the archive, then you’ll encounter security issues when attempting to use the Add-In.
Figure 1 – Unblocking the Archive
After you unzip the Add-In, you must install the Add-In in Visual Studio. The download includes an Install.cmd batch file for installing the Add-In. Unfortunately, however, the installer did not work on my machine because of path issues. Therefore, I followed these steps to install the Add-In:
1. Create a new folder named AddIns in your Documents\Visual Studio 2008 folder.
2. Copy all of the unzipped files from the download into the new AddIns folder
3. After launching Visual Studio, select the menu option Tools, Add-In Manager and enable the TDD Class Generator Add-In (see Figure 2).
Figure 2 – Enabling the TDD Class Generator Add-In
Admittedly, the project is very much in the infant stage. Don’t expect a fancy interface.
Before you can use the TDD Class Generator, you first must create a new C# ASP.NET MVC Web Application. Make sure that you create a test project. Also, you need to add references to both NUnit and Rhino Mocks to your test project.
After you create a new project, you use the TDD Class Generator Add-In by selecting the menu option Tools, Generate Class Under Test. Alternatively, you can just entry the keyboard combination Ctrl-Alt-Enter. Either method of launching the Add-In displays the dialog in Figure 4.
Figure 3 – Using the TDD Class Generator
Figure 4 – TDD Class Generator Dialog
Select the name of your application project and the name of your test project from the dropdown lists. If you complete the dialog by entering the value Models for Folder location and Movie for Class name and click the Generate button (well, the Generat button on my machine) then the following files are generated in the application project automatically:
\Models\Impl\Movie.cs
\Models\IMovie.cs
And, the following file is generated in the test project automatically:
\Models\MovieTester.cs
The goal of the tool is to set you on the right path. It doesn’t just create a Movie class. Instead, it creates a Movie class that implements an interface. It also assumes that you will need to mock the class. Therefore, the TDD Class Generator adds the mocking logic to the MovieTester.cs class automatically.
I think Eric Hexter’s approach is a great approach for making it easier to build ASP.NET MVC applications. Right now, there is a lot of repetitive file creation tasks involved when getting a new ASP.NET MVC application off the ground (Especially if you want to do things the right way). By building a library of ASP.NET MVC specific Add-Ins, you can eliminate these brainless, tedious tasks.

Where do I find the specific references for both NUnit and Rhino Mocks to my test project?
Thanks
Error 1 The type or namespace name ‘IDependency’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Dale Stewart\My Documents\Visual Studio 2008\Projects\MvcApplication6\MvcApplication6\Models\MoviesTester.cs 16 13 MvcApplication6
@geek50 – You need to download both NUnit and Rhino Mocks. Get NUnit at NUnit.org and Rhino Mocks at http://www.ayende.com/projects/rhino-mocks.aspx. After you download, you’ll need to add references to the DLLs to your test project.
Error 1 The type or namespace name ‘IDependency’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Dale Stewart\My Documents\Visual Studio 2008\Projects\MvcApplication6\MvcApplication6\Models\MoviesTester.cs 17 13 MvcApplication6
The project utilizes VS item templates, which are zip files with .cs files inside. You can modify those to meet your exact need and preference of the specific template. The IDependency does not exist and I utilize the Resharper Ad-in to make additional dependencies. I will monitor this post for more comments and respond.
for more information see my blog at http://hex.lostechies.com/
Stephen, your Tips give me much better understanding of ASP.NET MVC capabilities, thank you.
However I am still curious about one thing (outside current topic, sorry): how much ASP.NET MVC depends on RESTful routes? Or in other words: can I use ASP.NET MVC with old good “~/MyDirectory/Default.aspx?id=333″ mapped directly to file system? It might be useful for step-by-step migration from WebForms.
I’d really appreciate your explanations or ideas on that.
Very Good Work
Thanks
Hi !
i have downloaded the “LatestVersion.zip” and right click on it and select the properties but the “unblock” button is not in display ! what to do further ??
i have to go back to school to understand this….i hope i still have a time for that. TQ
i really like the info at this post thanks!!!
Interesting article.
Quitting Smoking Side Effects
Are you interested in getting rid of smoking side effects? In this article you will find some fascinating tips. It is often seen that some people start smoking to get relieved from the stress. They start using it for several occasions and soon they get trapped into its addiction
I really love to go across these blogs because they are very helpful and gets easier to handle all type of issues with your projects. Thanks Stephen!
I REALLY LIKE THE COMENTS VERY NICE POST
wow.. great post
i really like it thanks!
great post Stephen Walther ! Your are the best !
Hi I need to download both NUnit and Rhino Mocks. Help please.
Hi served me well through the information, thanks
Hi
thanks for the tips have helped me a lot.
Hello
cool this blog is great very good my friend keep it go
Hi
I really appreciate this info, please keep me inform
very interesting website, congratulations.
Hello
I really appreciate this info, please keep me inform.
Hello
I would be visiting this blog regularly. Thanks for sharing good information.
f3w43 It looks like DataContextExtensions.cs line 45 of the Save method should pass the primaryKeyName through to Update.
hey buddy! your doing some great stuff! keep it going!
Industrial Design | logo design | Multimedia Design
Advertising Design | graphic design
selam hi This sounds fascinating sıcak sohbet I’m going to read that tracing articlekısa aşk şiirleri when I have a moment.
Wow. erotik film izle is
şifalı bitkiler zayıflama de
çet sohbet fer
netlog ger
müzik dinle err
şarkı dinle
cüneyt arkın filmleri kk
isyan sözleri fer
hikayeler er
islami çet ff
adet sancısına ne iyi gelir hh
escort bayanlar der
bedava chat dd
chat odaları der
liseli kızlar derf
kızlarla sohbet fder
kızlarla chat
sohbet errAAA
Can you explain me which could be the effects for an adult to buy Viagra Online and have heart problems?
Where do I find the specific references for both NUnit and Rhino Mocks to my test project?
Thanks
As the users of HD Camcorders like Sony, Canon, Panasonic, this HD Video Converter is necessary to help us convert hd Video easily and quickly. The Converter for HD provides several practical editing functions to help you achieve ideal output effect. Trim function is to cut videos into clips which you can just convert and transfer to your player. Crop function helps you remove black bars around the movie. You could use Effect function to adjust video brightness, contrast, saturation and more parameters. More powerful and considerate functions are waiting for you to explore.
Mac Video Converter l Rip Blu Ray l VOB Converter