International Developer Logo Last Updated 25.07.08 at 11.48
On Sale
This months front cover, click to see the table of contents.
Subscribe
 
TUTORIALS

Using Mock Objects in Test Driven .NET Development


Neil Kidd   01.11.05



With just enough code to compile our test, we are ready to add the necessary functionality to the Employee class.
Step 3 - Write enough code to pass the test
Our SetName method takes a string parameter and assigns it to the Name property of the Employee object as shown below:
this.Name = newName;

Completing the SetName method gives us green lights for the NUnit test results.

Step 4 - Repeat
The next thing to do, of course, is to add more test methods to the test class and refactor the Employee class until it green lights for all the tests. If we decide to change the design of the class, such as making the Name property private, for example, NUnit will automatically inform us that the SetName test fails when it is next run. We would then need to use a GetName method in the test and re-engineer the Employee class appropriately.




   Previous Page  1 2 3 4 5 6 7 8 9 10 ... Next Page   

HAVE YOUR SAY
This article is rated  Rate this article