I have a convention for StructureMap that looks like this:
public class FakeRepositoriesConvention : IRegistrationConvention
{
public void Process(Type type, global::StructureMap.Configuration.DSL.Registry registry)
{
if (type.Name.StartsWith("Fake") && type.Name.EndsWith("Repository"))
{
string interfaceName = "I" + type.Name.Replace("Fake", String.Empty);
registry.AddType(type.GetInterface(interfaceName), type);
}
}
}
I want to implement unit tests for this, but I don't know how to do that.
My first thought was to send in a mocked Registry and just test that AddType() is called with the right parameters. I can't get that to work though, probably because AddType() is not virtual. Registry implements IRegistry but that doesn't help me since the Process method doesn't accept an interface.
So my question is - how can I test this?
(I'm using nUnit and RhinoMocks)