views:

111

answers:

1

I'm trying to get structuremap to build Fluent Nhibernate's SessionSource object for some of my intregration tests. The only problem is that Fluent's concrete implementation of ISessionSource (SessionSource) has 3 constructors:

    public SessionSource(PersistenceModel model) 
    {
        Initialize(new Configuration().Configure(), model);
    }

    public SessionSource(IDictionary<string, string> properties, PersistenceModel model)
    {
        Initialize(new Configuration().AddProperties(properties), model);
    }

    public SessionSource(FluentConfiguration config)
    {
        configuration = config.Configuration;

        sessionFactory = config.BuildSessionFactory();
        dialect = Dialect.GetDialect(configuration.Properties);
    }

I've tried configuring my ObjectFactory supplying an argument for the first constructor but it seems like it wants to try the second one.

How do I configure my ObjectFactory so that I can choose the first constructor or perhaps even another one if I decide to use that?

+2  A: 

In your registry you can do it like this:

SelectConstructor<SessionSource>(()=> new SessionSource((FluentConfiguration)null));
For<SessionSource>().Use<SessionSource>();
miensol