I'm currently using StructureMap to inject instances of NHibernate ISessions using the following code:
ObjectFactory.Initialize(x =>
{
x.ForRequestedType<ISession>()
.CacheBy(InstanceScope.PerRequest)
.TheDefault.Is.ConstructedBy(y => NHibernateSessionManager.Instance.GetSession());
});
I'm assuming that the CacheBy(InstanceScope.PerRequest) will properly dispose of the ISession it creates, but I'd like to make sure. What's the easiest way to test this?