Saturday 15 June 2013

visual studio 2010 - Unit Testing interface contracts in C# -


By using the code contract tool available in VS2010 beta 2, I have an interface, a contract class for that interface and two sections It is defined by the implementation of the interface.

Now that I have come to test the code, I want to test the implementation classes so that I know that their functionality is correct and I want to test the contract code so that I can know that my The conditions are correct.

I can test every contract statement in each implementation class, but it is clearly meaningless. I could write just one test on one of these implementation classes, but it seems a bit wrong, how to choose between them, to remember who changes the contracts, as you update.

I want to check the actual interface contract class, but compile all types of time warnings that the interface method is not available to test the interface contract. I know that the compilation code actually happens after compiling the code in my implementation sections (which I can see in ILDAM), but when I inspect the interface contract class methods, they are in MISL, but are empty . / P>

I'm missing something, or I just do not want to be possible. If not, then what is the "best practice" for this?

=== Edit ===

Here is a suggestion to implement the interface in a class (an internal test assembly) whose purpose is to test the interface contracts, Sound is sensible?

Examine your contracts like the unit is testing your unit tests because you do not You have to test your tests and trials.


No comments:

Post a Comment