.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

enabling ASP.NET MVC2 unit tests in VWD

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
As stated in http://forums.asp.net/t/1535916.aspx the unit tests are missing from the ASP.NET MVC 2 RTM source code, but are available on CodePlex at http://aspnet.codeplex.com/releases/view/41742).   After installing ASP.NET MVC2 RTM on Visual Web Developer 2008 Express, apparently unit tests are not enabled for VWD - when I create a new MVC2 project I don't get the "Create Unit Test Project" dialog box where I can say"Yes, create a unit test project". (I thought I was presented with that dialog box in earlier versions of either MVC2 RC or MVC1, but maybe not...) Given the source code on codeplex, is it possible to use that to enable unit tests for MVC2 for VWD Express?  If so, are the steps one have to take detailed somewhere?

View Complete Post

More Related Resource Links

Generation Test: Automated Unit Tests for Legacy Code with Pex


Creating and maintaining a unit test suite for legacy code can be a challenge. Pex automatically produces a small test suite with high code and assertion coverage.

Nikhil Sachdeva

MSDN Magazine December 2009

Bugslayer: Strengthening Visual Studio Unit Tests


Visual Studio 2005 brought so many new features to the table that it can seem almost overwhelming. One of the most exciting additions is the new unit testing features found in the Test menu on the main menu bar.

John Robbins

MSDN Magazine March 2006

Unit Testing Tips: Write Maintainable Unit Tests That Will Save You Time And Tears


Everybody's talking about unit testing and you want to get into the game too. But you don't want the tests to take up all your development time and energy. Fortunately Roy Osherove is here to dispel some testing myths and put you on the road to efficient unit testing.

Roy Osherove

MSDN Magazine January 2006

Unit tests for Action which uses RedirectToAction


I have Action method in a controller which uses RedirectToAction(actionName, routeValues[]) 

I want to write the unit test for action method to check the following - 

1. action name

2. ViewData after executing the RedirectToAction.

Someone know how to mock it , please help.

'File not found' in unit tests problem



I have a unit test that reads from an .xml file and it works fine on my local machine.

However, in TFS when I create a new build it gives the following exception:

Failed    GetArticleByIdTestOptimal        Test method Test.ArticleSystemTest.GetArticleByIdTestOptimal threw exception:  System.Xml.XmlException: ImportFromFile filePath=[.\Articles1to5.xml]. --->  System.IO.FileNotFoundException: Could not find file 'c:\buildarea\TestResults\tfservice 2010-10-19 11_52_19_Any CPU_Release\Out\Articles1to5.xml'..  

Is there some reason why a unit test could pass locally but not in TFS? I've verified that the file is on the build server.

Installing SP1 caused unit tests to fail (checking for classes derived from UserControl)


I have unit tests that check to see if a certain class is derived from a given abstract class. Once I installed Visual Studio 2008 SP1 and KB971092, these unit tests start failing.

However, the odd part is, they only fail when I am checking for a class that is derived from an abstract user control.  So if I use the algorithm to see if Class1 is derived from AbstractClass1, the unit test passes.  If I check to see if View1 is derived from AbstractView1 : UserControl, the unit test fails.  The actual line of code the unit test is failing on is



The code around the failing line is


 // Try to load the assembly
Assembly ____ = Assembly.LoadFrom(assemPath);
// Now that the assembly is loaded get all the types
Type[] types = ____.GetTypes();
// Loop through all the types only returning nonabstract classes
// That are subclasses of the given class
foreach (Type type in types)
  if ((type.IsSubclassOf(subClass)) && (type.IsInterface == false

How can I speed up unit tests which use reflection in Visual Studio 2010?


Hi there,

I was thinking about using reflection for unit tests where 2 objects will be compared for equality and GetProperty() and GetFields() methods will be used extensively. However, I know that the performance impact will be very significant. In fact, couple of my coworkers used reflection for a deep copy of some sourceobject to targetobject. The code is absolutely elegant, beautiful and does exactly what it's supposed to do. The problem is they had to scrap it because it was really slow. So, is all lost when it comes to using reflection in unit tests or is there a way to implement it without a ridiculous performance hit? Thanks a lot in advance.

Unit Testing SharePoint - Past, Present, and Sporm

As I described in SharePoint: The Wild West of Software Development there is a serious problem when you develop for SharePoint: ensuring quality through unit testing is really, really hard. And that's where a new open source tool just released today called sporm (SharePoint Object Relational Mapper) comes in. While sporm provides many benefits besides simplified unit testing I wanted to focus on this topic first, because sporm's approach, which models the entity framework in the way it supports POCO's, is a unique feature not available with other SharePoint tools like LINQ to SharePoint.

Enabling Users to Maintain SharePoint Content

When SharePoint is installed as a corporate intranet, there is a considerable amount of effort involved in maintaining the content to keep the site relevant. As we discussed in the first few parts of this series, SharePoint has many built-in features to reduce the burden on the site administrator.

Some areas of the site usually contain less-dynamic information. Internal memos and corporate policies are common examples of this information. One option for this information is to post these documents in a document library. Documents in a library are often stored in a few different formats: Word, Acrobat (PDF), or HTML. Each of these formats has its drawbacks.

Enabling Users to Maintain SharePoint Content

When SharePoint is installed as a corporate intranet, there is a considerable amount of effort involved in maintaining the content to keep the site relevant. As we discussed in the first few parts of this series, SharePoint has many built-in features to reduce the burden on the site administrator.

Performance Tests: Precise Run Time Measurements with System.Diagnostics.Stopwatch

Everybody who does performance optimization stumbles sooner or later over the Stopwatch class in the System.Diagnostics namespace. And everybody has noticed that the measurements of the same function on the same computer can differ 25% -30% in run time. This article shows how single threaded test programs must be designed to get an accuracy of 0.1% - 0.2% out of the Stopwatch class. With this accuracy, algorithms can be tested and compared.

MVC2 issue - Stuck. Trying to create a cms with nested partials


I am currently trying to display multiple items on a single page. I am not sure as to how to tackle this. What I have is a database table that has all the page data in. I have this run as a PagesController and this works fine. However what I would like to do is, if say the Products page is selected via the menu, I want to pull back not only the Products page html but also get all the products, and even be able to pull them through via category. I was trying to use a partial view, but I can't get it to work. The same would be for other pages, having partial views to display the other content, ie if Gallery is selected, the page html for Gallery shows and it then can push to a partial view that pulls all the gallery images from the gallery db table and so on. 

Maybe I am tackling this the wrong way. I have the pages stored in the db to allow for a CMS system I have setup. Maybe I need to use models for all the other items(Products, Gallery, Videos and such) and use the partial for the page html?

Any help would be greatly appreciated as I am confused.

areas mvc2 iis 6.0


hi all,

i have another problem. I am trying to deploy my MVC2 website on iis 6.0. I have added the following to my global.asax:


routes.MapRoute("Default","{controller}.mvc/{action}/{id}", new {controller = "Home", action = "Index", id = UrlParameter.Optional } );

I added the ".mvc" extention because i read that iis 6 needs this. And it works. BUT!! I also use areas, and this is something iis 6 does not understand.

I have the following:
No Areapath: Home.mvc/Index (works fine, no area used)
Areapath: Projects/Overview/Index (does not work!!)

I don't now how to solve this, i hope somebody can help me.




reading values from config files in NUnit tests


One of my NUnit tests has to read in some values from config files.  In my main application this process works perfectly well, however when I run the unit test, the code that reads in the values from the config files doesnt read anything in.  Ive tried putting app.config in my unit test project (I even tried web.config) but nothing seems to work.  Are there any special steps involved when reading from config files in an nunit test ?

Test-Driven Design: Using Mocks And Tests To Design Role-Based Objects


Use Test-Driven Development with mock objects to design object oriented code in terms of roles and responsibilities, not categorization of objects into class hierarchies.

Isaiah Perumalla

MSDN Magazine June 2009

Patterns in Practice: The Unit Of Work Pattern And Persistence Ignorance


Jeremy Miller continues his discussion of persistence patterns by reviewing the Unit of Work design pattern and examining the issues around persistence ignorance.

Jeremy Miller

MSDN Magazine June 2009

Test Run: Automating UI Tests In WPF Applications


This month we describe techniques for automating UI testing in Windows Presentation Foundation applications.

James McCaffrey

MSDN Magazine March 2009

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend