public void ShouldSaveChanges() { var singleSession = mocks.DynamicMock<ISession>(); Expect.Call(singleSession.Flush); mocks.ReplayAll(); var sharedUnitOfWork = new SingleNHibernateUnitOfWork(singleSession); sharedUnitOfWork.SaveChanges(); mocks.VerifyAll(); }
public void ShouldDispose() { var singleSession = mocks.DynamicMock<ISession>(); Expect.Call(singleSession.Dispose); mocks.ReplayAll(); var sharedUnitOfWork = new SingleNHibernateUnitOfWork(singleSession); sharedUnitOfWork.Dispose(); mocks.VerifyAll(); }
public void ShouldGetCurrentSession() { var singleSession = mocks.DynamicMock<ISession>(); mocks.ReplayAll(); var sharedUnitOfWork = new SingleNHibernateUnitOfWork(singleSession); var session = sharedUnitOfWork.Session; mocks.VerifyAll(); Assert.Equal(singleSession, session); }
public PersistenceTest() { NHibernate.Cfg.Configuration configuration = null; SessionFactory = Fluently.Configure() .Database( SQLiteConfiguration.Standard.InMemory().DoNot.ShowSql ) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibernateConfiguration>()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<PersistenceTest>()) .ExposeConfiguration(cfg => configuration = cfg) .CurrentSessionContext<ThreadStaticSessionContext>() .BuildSessionFactory(); UnitOfWorkSession = SessionFactory.OpenSession(); new SchemaExport(configuration).Execute(false, true, false, UnitOfWorkSession.Connection, null); unitOfWork = new SingleNHibernateUnitOfWork(UnitOfWorkSession); }