public void Save_Session_For_Reuse() { var uow = new NHibernateUnitOfWork(_mockSession.Object); Assert.AreSame(uow.Session, _mockSession.Object); uow.Dispose(); }
public void Open_A_New_Transaction() { var uow = new NHibernateUnitOfWork(_mockSession.Object, IsolationLevel.ReadUncommitted); _mockSession.Verify(ms => ms.BeginTransaction(It.IsAny <IsolationLevel>())); uow.Dispose(); }
public void Use_IsolationLevel_Of_ReadCommitted_By_Default() { var uow = new NHibernateUnitOfWork(_mockSession.Object); _mockSession.Verify(ms => ms.BeginTransaction(IsolationLevel.ReadCommitted)); uow.Dispose(); }
protected virtual void Dispose(bool disposing) { if (_unitOfWork != null) { _unitOfWork.Dispose(); } }
// 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(); }
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(); }
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; } }
public void dispose_should_dispose_the_transaction() { _uow.Dispose(); _transaction.AssertWasCalled(t => t.Dispose()); }
private void EndUnitOfWork() { unitOfWork.SaveChanges(); unitOfWork.Dispose(); }