ObjectSharp Blogs

You are currently viewing

Dave Lloyd's 2 Cents

A .NET Developer's Perspective


Test Driven Development with VS 2010

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.

image

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.

image

By switching to Suggestion mode IntelliSense will display an edit control allowing you to continue typing even though there are no matches.

image

IntelliSense will even suggest this new class before it’s actually created.

image

Once you have completed your statement you can use the CTRL+. smart tag to generate this class.

image

Or generate a new type altogether, allowing you to select the project it should go in.

image

You can use this new feature to generate a method or property stub also a class, interface, struct or enum.

Comments

    No Comments

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS