Test Driven Development with VS 2010
Posted: Saturday, November 07, 2009 6:03 PM
by
dave
Filed under: VS2010
Test Driven Development proposes you should: write the test, watch it fail, write the code, run the test to see it pass, refactor your code.
This is difficult when your code won’t compile because you haven’t created the method or even the class you are writing a test for. When you are in the middle of writing unit tests you don’t want to have to switch over to create a class with an empty method, it breaks your train of thought.
In VS 2008 MS introduced the Generate Method Stub on the CTRL+. smart tag.
In 2010 they have taken this a step further. There are two new features I want to talk about here IntelliSense Suggestion Mode and Generate From Usage.
IntelliSense has two modes now Completion Mode and Suggestion Mode. You can toggle between these modes with the key sequence CTRL+ALT+SPACEBAR.
In completion mode if you entered the name of a type that does not exist, IntelliSense will make suggestions that match what you typed. I’m sure you have noticed that this can be annoying, with the wrong key stroke you end up with code you didn’t want.
By switching to Suggestion mode IntelliSense will display an edit control allowing you to continue typing even though there are no matches.
IntelliSense will even suggest this new class before it’s actually created.
Once you have completed your statement you can use the CTRL+. smart tag to generate this class.

Or generate a new type altogether, allowing you to select the project it should go in.
You can use this new feature to generate a method or property stub also a class, interface, struct or enum.
If you would like to receive an email when updates are made to this post, please register here