My question has been answered here.
Hi Nathan
There's a couple of different options here.
Using a batch, you can call the AddExportedObject method to add a mock instance to the container. AddExportedObject allows you to specify the contract for the instance that you are adding. i.e. batch.AddExportedObject(mockLogger, typeof(ILogger));
You an also create a custom export provider to allow you add mock instances. If you follow this link, here are some utils that I use. http://pastie.org/467842. Within you'll find a FakeExportProvider, along with FakeExportDefinitions. The FakeExportDefinitions take a func for the instance. This means you can pass it an instance, or even directly create a mock.
Here's sample code to illustrate usage.
protected override void Context()
{
MockCache = MockRepository.GenerateStub<ICache>();
var metadata = new Dictionary<string, object> ()
var cacheDefinition = new FakeInstanceExportDefinition(typeof(ICache), MockCache, metadata);
FakeProvider = new FakeExportProvider(f => ((FakeInstanceExportDefinition)f).Instance);
FakeProvider.AddExportDefinitions(cacheDefinition);
CacheExport = FakeProvider.GetExport<ICache>();
}
Now above I am querying the export provider directly. However, our container allows passing in an export provider in it's construction. So you can do this...
var container = new CompositionContainer(null, FakeProvider).
HTH
Glenn