Visual Studio 2010 and TDD


I have been playing with Visual Studio 2010 a lot lately. I am, overall, impressed with where they are going, but I have found that the CTP is stil a bit rough. For the record, I have not gotten an dog food drop from Microsoft, so I can freely talk about my findings.
 
It is nice that Micrsooft is finally adopting a test first approach. I can now write my tests up front and then implement the class and the methods from the test code. One thing I have noticed, however, it only recognizes classes without a static method. For example, I wrote the following test code.
 
[TestMethod]
public void
       should_return_a_value_between_1_and_10_with_null_seed()
{
 int? min = 1;
 int? max = 10;
 int? seed = null;
 
 int actual = RandomGenerator.GetRandomInt32(min, max, seed);
 Assert.IsTrue(actual >= min, "Value is less than min value.");
 Assert.IsTrue(actual <= max, "Value is more than max value.");
}
There is nothing stellar about this particular test method. It is simply a call on a static method. Yet, the IDE does not respect the control + period to bring out the drop down. The solution, in the CTP is to write a line like the following:
 
RandomGenerator generator = new RandomGenerator();
 
This will allow you to use control + period and create the class. One other little glitch in the process. The class created will bear the namespace of the test project, even when you create it in another project. This is minor, but I hope they have this respecting the actual class by RTM.
 
I have one wish on my wish list, as well. I wuld like to have it create the project, if it is not already present. Under the current implementation, I have to creat the project and then run the refactor to create the class. This is not a major deal, but it would be nice to have it create the entire project. Yes, this menas I have to use full syntax in my test code, but what power it would yield.
 
Peace and Grace,
Greg
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: