PEX Tool

PEX is a Microsoft tool that analyzes source code to help develop a minimal set of test cases which will cover all required scenarios. It makes use of Parametrized Unit Testing. This method calls the code with parameters, then verifies the output based on an expected output. The PEX tool can generate output unit test data for tools such as NUnit. PEX contains a framework called Stubs that creates stubs for .NET as C# source code.

The PEX tool is useful for general testing. However it is especially useful for testing refactored source code. So you can take your legacy code and refactor it. PEX can generate unit tests to ensure that the refactored code behaves the same as the legacy version of the code. This addresses one of the chief concerns about refactoring. If you have a tool which ensures that refactoring does not break existing functionality, it might be easier to justify refactoring efforts.