public void GetEntitySet_Returns_NHibernateEntitySet_With_Session()
        {
            // Arrange
            ISession session = new Mock<ISession>().Object;
            NHibernateDataContext context = new NHibernateDataContext(session);

            // Act
            NHibernateEntitySet<Object> entitySet = context.GetEntitySet<Object>().AssertCast<NHibernateEntitySet<Object>>();

            // Assert
            Assert.AreSame(session, entitySet.Session);
        }
        public void GetEntitySet_Returns_NHibernateEntitySet_With_NHibernateQueryable()
        {
            // Arrange
            ISession session = new Mock<ISession>().Object;
            NHibernateDataContext context = new NHibernateDataContext(session);

            // Act
            NHibernateEntitySet<Object> entitySet = context.GetEntitySet<Object>().AssertCast<NHibernateEntitySet<Object>>();

            // Assert
            Assert.IsNotNull(entitySet.Query);
        }
        public void GetEntitySet_Returns_NHibernateEntitySet()
        {
            // Arrange
            ISession session = new Mock<ISession>().Object;
            NHibernateDataContext context = new NHibernateDataContext(session);

            // Act
            IEntitySet<Object> entitySet = context.GetEntitySet<Object>();

            // Assert
            Assert.IsInstanceOfType(entitySet, typeof(NHibernateEntitySet<Object>));
        }
        public void Dispose_Disposes_Session()
        {
            // Arrange
            var mockSession = new Mock<ISession>();
            NHibernateDataContext context = new NHibernateDataContext(mockSession.Object);

            // Act
            context.Dispose();

            // Assert
            mockSession.Verify(s => s.Dispose());
        }
        public static NHibernateDataContext GetDataContext(IQueryable query)
        {
            var provider = query.Provider as DefaultQueryProvider;

            if (provider == null)
            {
                return(null);
            }

            var session = SessionField.GetValue(provider, null);

            if (session == null)
            {
                return(null);
            }

            return(NHibernateDataContext.GetBySession(session));
        }
Example #6
0
 public NHibernateMigration(NHibernateDataContext dataContext)
 {
     _dataContext = dataContext;
 }
        public void SaveChanges_Flushes_Session()
        {
            // Arrange
            var mockSession = new Mock<ISession>();
            NHibernateDataContext context = new NHibernateDataContext(mockSession.Object);

            // Act
            context.SaveChanges();

            // Assert
            mockSession.Verify(s => s.Flush());
        }
Example #8
0
 public NHibernateMigration(NHibernateDataContext dataContext)
 {
     _dataContext = dataContext;
 }