Wednesday, March 9, 2011

Having fun with Pex

Pex is a white box testing framework for .NET that integrates directly into Visual Studio 2010. Currently it’s in development by Microsoft Research. The framework uses symbolic execution to test the certain paths of a given method. It tries to find proper boundary conditions and applies them to the method. After execution the results for each input value are displayed and you can easily identify incorrect behavior. Together with the isolation framework Moles you can use Pex to automatically create white box tests for your methods. For further information to Pex and Moles have a look at:

Now to the fun part: There’s an online version of Pex, called Pex for fun at It’s a very simplified version of the fully featured framework mentioned above. Pex for fun features a set of so called puzzles. You can either watch a given method implementation, try to understand what it does and figure out which input values would lead to a failure or you can try to implement a secret method, which is really fun and sometimes difficult too. You just get an empty method stub. Your task is to implement it according to a given implementation which is kept secret. The only hints you get are by asking Pex. The framework compares the paths of your method with the secret implementation. If the results are the same for all determined input values, than you win that certain puzzle. It’s a kind of test driven development. You just know the input values and the according results and need to find the correct implementation. If you sign in with your Live Id you can even create your own puzzles and you gain points for solving puzzles of other users. It’s a good exercise to test both your analytical and your programming skills.

Monday, March 7, 2011

MVVM "In the Box"

Recently I found a really cool MVVM training kit that integrates with guidance directly into Visual Studio 2010. It targets WPF and was created by Karl Shifflett. The extension package can be found on the Visual Studio Gallery, so you can just install it into the IDE.
After installation there’s a new entry in the new projects wizard called “In the Box”. The template behind creates a new Visual Studio solution with a number of MVVM related projects. Additionally you get a guidance browser which can be used to display appropriate information to certain concepts and MVVM related topics. Within the projects you get some minimalistic samples that demonstrate the use of MVVM and concepts like IoC. The advanced examples rely on Prism and Unity as the dependency injection and IoC framework. Besides the sample application there’s a test project too, which shows how to write unit tests within Prism applications with the Visual Studio test runtime and Moq.
So if you want to learn MVVM quickly and get your hands on some practical examples, just give it a try.