How to verify StructureMap is disposing of objects properly
Posted
by Kevin Pang
on Stack Overflow
See other posts from Stack Overflow
or by Kevin Pang
Published on 2010-04-04T16:25:54Z
Indexed on
2010/04/04
16:33 UTC
Read the original article
Hit count: 261
structuremap
|nhibernate
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?
© Stack Overflow or respective owner