public void ShouldExecuteDisposeOlnyOne() { SessionFactoryProvider sfp; ISessionFactory sf1; bool disposed = false; using (sfp = new SessionFactoryProvider()) { sfp.BeforeCloseSessionFactory += ((sender, e) => disposed = true); sf1 = sfp.GetFactory(null); } Assert.That(disposed); Assert.That(sf1.IsClosed, "The session-factory should be closed."); disposed = false; sfp.Dispose(); Assert.That(!disposed); }