views:

140

answers:

3

I'm looking for sample solution(s) that demonstrate various kinds of unit tests in C# using best practices. Also I require the examples to use the Visual Studio test tools. I know that there are a number of books and web sources on unit testing, but they don’t use the Visual Studio tools for writing their unit tests. I don’t want really basic examples such as can be found here. I am looking to move to the next level of unit-testing and I can’t find advanced examples of unit testing that use Visual Studio 2010 or even VS 2008.

EDIT: To be more clear; I am working on a project where I have to use the testing tools that are built in to Visual Studio. I am not looking for info on any 3rd party testing tools.

+1  A: 

Have you considered nUnit?, there are plenty of advanced testing examples if you take a poke around google.

Edit:

Just stumbled across another Unit Testing suite, MbUnit which seems to be aimed at more advanced testing.

Jamie Keeling
Yes, there are lots of examples, but not a lot that use Visual Studio.
Bill W
When you say uses "Visual Studio" do you mean as in one solution that integrates with VS as a complete solution? I believe nUnit uses an additional application to display test results but the initial tests are written and set up in the IDE.
Jamie Keeling
TestDriven.Net can give you nUnit through VS. http://www.testdriven.net/
sixlettervariables
I believe the Poster wants to know about the visual studio test tools... you know... the ones that ship with the IDE... that do thier job just fine for small to medium sized projects... that is shunned for no good reason. If you are used to nunit, use nunit, but don't push third party techs when they're asking about the VS testing tools you insensitive clod!
Firoso
Yes, I specifically want to know about Visual Studio testing tools, not other testing tools. I am working on a project where I have to use the VS tools, not any 3rd party stuff.
Bill W
@Firoso I was merely giving the user a variety of choices, I mentioned NUnit as it is a very good alternative to the built in testing tools that are present in VS. You're more than welcome to suggest some for the poster instead of criticising.
Jamie Keeling
Ah, the Posters edit to the question makes things clearer.
Jamie Keeling
Prior to the edit it wasn't very specific. Regardless, VS's testing isn't terribly great beyond trivial assertions.
sixlettervariables
@sixlettervariables - "I'm looking for sample solution(s) that demonstrate various kinds of unit tests in C# using best practices. Also I require the examples to use the Visual Studio test tools." from the first draft... learn to read.
Firoso
@Firoso Care to suggest anything? You're more than happy to point out the flaws from other people's ideas but yet you haven't contributed yourself.
Jamie Keeling
+2  A: 

Visual Studio unit testing intro and TDD: Test-Driven Development with Visual Studio 2008 Unit Tests may be more to what you are wanting to find perhaps.

nUnit's adoption before Microsoft put built-in unit test support is my guess for why the built-in testing abilities are shunned to some extent. nAnt/nUnit and CI tools may be used outside of the Team System that has a substantial cost in some cases I'd think. Though for those open to 3rd party ideas, here are a couple of other examples:

Using NUnit in Visual Studio 2010 may be a blog example that shows you nUnit + VS2010 as it is possible to do that.

Easy Debugging of NUnit Tests from Visual Studio 2008 Professional would be an example for 2008.

By advanced do you mean things like Rhino Mocks?

JB King
I am not looking for 3rd party tools and no, I am not looking for a mocking framework.
Bill W
A: 

The closest thing that I have found so far is the Enterprise Library; although it is not written as a unit test tutorial it does have a large number of unit tests and code written using best practices. If no one else comes up with something better, I will mark this as the answer.

Bill W