This post discusses key ways of improving the effectiveness and code coverage on unit tests, using the Visual Studio Test Framework, including the developing Moles and Pex technologies. Other frameworks and harnesses such as nUnit, Moq, etc. are not discussed in this post.
Moles is Microsoft's code instrumentation, or mock framework, used to isolate environment dependencies. Moles was created expressly to enable Pex to function. Moles is discussed in greater detail, after the break.
Pex intelligently examines the logic branches of the code to be tested, and then generates a series of input values that should or should not fail, thereby maximizing test code coverage.
Before we start talking about Moles and Pex, there are some elementary, yet vitally important topics to review about unit testing. Adhering to these rules play into the effectiveness of Moles and Pex. I strongly advise reading, before moving on to part 2, but I really can't stop you, can I? (or can I? Muahaha!)