Project Description
ContainerVariations is a collection of similar unit tests projects, each applied to a different Inversion of Control container. If successful, it will provide a consistent and comprehensive set of examples for popular .NET IoC containers. It is developed in C#.

There are a number of Inversion of Control (IoC) containers available to the .NET community, and it is difficult to decide confidently which container to use when first approaching the genre. They all have vastly different configurtion APIs, and each takes a considerable investment to understand. Since configuration options are one of the most important factors in selecting a container, this is a significant barrier to entry.

Similarly, they have all been developed in different contexts, so while their common functionality is vast, the subtleties in how they operate are easy to miss. For example, some containers hold references to all the components they create (for very good reasons), while others discard any reference to the instance once it is returned.

This kind of information is very useful, but not the kind of thing that is suited to exploration in detail at a Code Camp. So I've created this project as a supplement to my Code Camp presentations. It is designed to provide concrete examples of container configuration in various scenarios that I have either encountered myself, or read about. I is also intended to highlight some of the philosophical differences between containers so that new users can make more informed decisions about which container to use.

At its heart, this project is based on the notion that one good way to learn about an API is to exercise it via unit tests. With that in mind, I've created a VS2008 solution that is built around an abstract NUnit test fixture with a test method for a number of IoC container usage scenarios. Then, for each specific container there is a separate project that implements each of these test methods for that IoC container.

This provides a sort of Rosetta Stone for comparing multiple IoC containers' approach to various usage stories.

In no way does this project seek to identify a best IoC container, or make any recommendations as to the fitness of any container.

Sadly, this project has a finite number of resources, so initially it compares only AutoFac, Castle Windsor, StructureMap and Unity. Hopefully others will be added. Also, my understanding of each of these containers is not infallible. So beware that I may not have used the best and clearest methods to test these IoC containers. As these arise, I will correct them.

Last edited Jun 25, 2009 at 4:50 PM by ccrary, version 2