Sunday, 3 May 2009

Updated templates for in ASP.NET MVC RTM


  • Visual Studio 2008 Pro
  • v1.5 (build has very few tests by default, so I have adapted the standard Visual Studio tests generated for ASP.NET MVC web applications. This resulted in two files: AccountControllerTests.cs and HomeControllerTests.cs (the last one is similar with HomeControllerFacts.cs)

The template for ASP.NET MVC unit testing can be found on the following location:

After unpacking the content of the template to a temp folder, we must place the new files in the Controllers folder, and update the content of MvcTemplate.csproj and MyTemplate.vstemplate:


  <Compile Include="ControllersHomeControllerFacts.cs" />
  <Compile Include="ControllersHomeControllerTests.cs" />
  <Compile Include="ControllersAccountControllerTests.cs" />

<Project TargetFileName="MvcTemplate.csproj" File="MvcTemplate.csproj" ReplaceParameters="true">
  <Folder Name="3rdParty" TargetFolderName="3rdParty">
    <ProjectItem ReplaceParameters="false" TargetFileName="xunit.dll">xunit.dll</ProjectItem>
  <Folder Name="Controllers" TargetFolderName="Controllers">
    <ProjectItem ReplaceParameters="true" TargetFileName="HomeControllerFacts.cs">HomeControllerFacts.cs</ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="HomeControllerTests.cs">HomeControllerTests.cs</ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="AccountControllerTests.cs">AccountControllerTests.cs</ProjectItem>

After re-packing the template and replacing the original one, the only thing left to do is running devenv /setup in the %VS2008%Common7IDE folder in order to update the template cache of Visual Studio.

The updated template can be downloaded from here - please rename the file to