public void Commit_also_commits_transaction()
        {
            var session = new Mock<ISession>();
            var transaction = new Mock<ITransaction>();
            var context = new Mock<CurrentSessionContext>();
            var sessionFactory = new Mock<ISessionFactory>().As<ISessionFactoryImplementor>();

            session.Setup(session2 => session2.SessionFactory).Returns(sessionFactory.Object);
            session.Setup(session3 => session3.BeginTransaction()).Returns(transaction.Object);

            sessionFactory.Setup(factory => factory.OpenSession()).Returns(session.Object);
            sessionFactory.Setup(implementor => implementor.CurrentSessionContext).Returns(context.Object);

            var work = new HibernateUnitOfWork(sessionFactory.Object);

            work.Commit();

            transaction.Verify(transaction1 => transaction1.Commit());
        }
        public void Dispose_also_disposes_of_session()
        {
            var session = new Mock<ISession>();
            var context = new Mock<CurrentSessionContext>();
            var sessionFactory = new Mock<ISessionFactoryImplementor>();

            sessionFactory.Setup(factory => factory.OpenSession()).Returns(session.Object);
            session.Setup(session2 => session2.SessionFactory).Returns(sessionFactory.Object);
            sessionFactory.Setup(implementor => implementor.CurrentSessionContext).Returns(context.Object);

            var work = new HibernateUnitOfWork(sessionFactory.Object);

            work.Dispose();

            session.Verify(session1 => session1.Dispose());
        }