Unit Testing the Metric Dashboard – Part 2

This is a continuation of the unit testing the Metric Dashboard series, you can find part 1 here

Passing a fake object to constructor

At one point I had to pass a fake object into the constructor. Here I used a feature that will be available in our next versions. This feature currently called intelliTest makes it much easier to create fake objects without needing to go back and forth in the code.

Stage one – when in a correct position the intelliTest window appears

image[2]

Clicking it opens a new window with the options of types to fake

image[7]

Choosing the Fake, will:

  • Create the fake in the test code
  • Insert the local variable in the method
  • Add the [Isolated] attribute to the test
  • Add the correct using statements and
  • Add the correct references to the project

image[8]

It is really great fun using this feature as it take away all the plumbing work and sets everything up for me.

Add Comment

Required fields are marked *. Your email address will not be published.