One of the 6 sessions I and Mikael Nitell is running on MSDN Live 2010 here in Norway is about Code Quality, and part of that session goes through the use of Code Contracts and Pex. Both fantastic tools ! They can be used together, but are also completely independent from each other, and each can be used single.
Code Contracts has to downloaded separately from VS 2010 (works also on VS 2008). Start looking at http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx . This download is a free download. Code Contracts originates form the ideas of Bertrand Meyer – Design by Contract, take a look here.
Pex is found on the MSDN Subscription download, so it requires an active MSDN Subscription. Start to get it from here http://research.microsoft.com/en-us/projects/pex/downloads.aspx . The current version as of 14.4.10 is 0.9, which works with the 2010 RC. A new version is due this week. Pex is a tool to generate unit tests, and does this very intelligently. Perfect to make tests for legacy code, but also to make sure you get all paths tested. See the Reference information and project startup information.
A nice presentation on how Pex and Code Contracts can work together can be found here.