When building unit tests, you almost always need to take advantage of a Mock Object framework. A Mock Object framework enables you to create mocks and stubs for the classes in your application.
For example, you can use a Mock Object framework to generate a mock version of your repository class. That way, you can use the mock repository class instead of the real repository class in your unit tests. Using the mock repository enables you to avoid executing database code when executing a unit test.
Visual Studio does not include a Mock Object framework. However, there are several commercial and open source Mock Object frameworks available for the .NET framework:
Moq - This framework is available under the open source BSD license. You can download Moq from http://code.google.com/p/moq/.
Rhino Mocks - This framework is available under the open source BSD license. You can download Rhino Mocks from http://ayende.com/projects/rhino-mocks.aspx.
Typemock Isolator - This is a commercial framework. You can download a trial version from http://www.typemock.com/.