Ejemplo n.º 1
0
            public void Save_Session_For_Reuse()
            {
                var uow = new NHibernateUnitOfWork(_mockSession.Object);

                Assert.AreSame(uow.Session, _mockSession.Object);
                uow.Dispose();
            }
Ejemplo n.º 2
0
            public void Open_A_New_Transaction()
            {
                var uow = new NHibernateUnitOfWork(_mockSession.Object, IsolationLevel.ReadUncommitted);

                _mockSession.Verify(ms => ms.BeginTransaction(It.IsAny <IsolationLevel>()));
                uow.Dispose();
            }
Ejemplo n.º 3
0
            public void Use_IsolationLevel_Of_ReadCommitted_By_Default()
            {
                var uow = new NHibernateUnitOfWork(_mockSession.Object);

                _mockSession.Verify(ms => ms.BeginTransaction(IsolationLevel.ReadCommitted));
                uow.Dispose();
            }
Ejemplo n.º 4
0
 protected virtual void Dispose(bool disposing)
 {
     if (_unitOfWork != null)
     {
         _unitOfWork.Dispose();
     }
 }
Ejemplo n.º 5
0
        // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
        // ~UnitTest1() {
        //   // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
        //   Dispose(false);
        // }

        // This code added to correctly implement the disposable pattern.
        public void Dispose()
        {
            UnitOfWork.Dispose();
            // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
            Dispose(true);
            // TODO: uncomment the following line if the finalizer is overridden above.
            // GC.SuppressFinalize(this);
        }
        public void Add(StockLevelModel stockLevel)
        {
            NHibernateUnitOfWork unitOfWork = (NHibernateUnitOfWork)UnitOfWork.Start();
            IRepository <StockLevelModel, int> stockLevelRepository = new NHibernateRepository <StockLevelModel, int>(unitOfWork);

            stockLevelRepository.Add(stockLevel);
            unitOfWork.SaveChanges();
            unitOfWork.Dispose();
        }
Ejemplo n.º 7
0
        public void Add(WarehouseModel warehouse)
        {
            NHibernateUnitOfWork unitOfWork = (NHibernateUnitOfWork)UnitOfWork.Start();
            IRepository <WarehouseModel, int> warehouseRepository = new NHibernateRepository <WarehouseModel, int>(unitOfWork);

            warehouseRepository.Add(warehouse);
            unitOfWork.SaveChanges();
            unitOfWork.Dispose();
        }
Ejemplo n.º 8
0
        public void DisposeShouldCallSessionDisposeAndSetToNull()
        {
            using (mocks.Record())
            {
                factory.Expect(f => f.OpenSession()).Return(session).Repeat.Twice();
                session.Expect(s => s.Close());
                session.Expect(s => s.Dispose());
            }

            using (mocks.Playback())
            {
                var localSession = unitOfWork.Session;
                unitOfWork.Dispose();

                var localSession2 = unitOfWork.Session;
            }
        }
Ejemplo n.º 9
0
        public void dispose_should_dispose_the_transaction()
        {
            _uow.Dispose();

            _transaction.AssertWasCalled(t => t.Dispose());
        }
 private void EndUnitOfWork()
 {
     unitOfWork.SaveChanges();
     unitOfWork.Dispose();
 }