예제 #1
0
        public void BeginTransaction_Throws_InvalidOperationException_When_Transaction_Already_Running()
        {
            var mockContainer = MockRepository.GenerateStub<IObjectContainer>();
            var unitOfWork = new Db4oUnitOfWork(mockContainer);
            unitOfWork.BeginTransaction();

            Assert.That(unitOfWork.IsInTransaction);
            Assert.Throws<InvalidOperationException>(() => unitOfWork.BeginTransaction());
        }
예제 #2
0
        public void BeginTransaction_Throws_InvalidOperationException_When_Transaction_Already_Running()
        {
            var mockContainer = MockRepository.GenerateStub <IObjectContainer>();
            var unitOfWork    = new Db4oUnitOfWork(mockContainer);

            unitOfWork.BeginTransaction();

            Assert.That(unitOfWork.IsInTransaction);
            Assert.Throws <InvalidOperationException>(() => unitOfWork.BeginTransaction());
        }
예제 #3
0
 public void Flush_Does_Nothing_When_A_TransactionHas_Already_Been_Started()
 {
     var mockContainer = MockRepository.GenerateMock<IObjectContainer>();
     var unitOfWork = new Db4oUnitOfWork(mockContainer);
     unitOfWork.BeginTransaction();
     unitOfWork.Flush();
     mockContainer.AssertWasNotCalled(x => x.Commit());
     mockContainer.AssertWasNotCalled(x => x.Rollback());
     mockContainer.VerifyAllExpectations();
 }
예제 #4
0
        public void Begin_Transaction_Should_Start_A_New_Transaction_With_Default_IsolationLevel()
        {
            var mockContainer = MockRepository.GenerateMock<IObjectContainer>();
            var unitOfWork = new Db4oUnitOfWork(mockContainer);
            var transaction = unitOfWork.BeginTransaction();

            Assert.That(unitOfWork.IsInTransaction);
            Assert.That(transaction, Is.Not.Null);
            mockContainer.VerifyAllExpectations();
        }
예제 #5
0
        public void Begin_Transaction_Should_Start_A_New_Transaction_With_Default_IsolationLevel()
        {
            var mockContainer = MockRepository.GenerateMock <IObjectContainer>();
            var unitOfWork    = new Db4oUnitOfWork(mockContainer);
            var transaction   = unitOfWork.BeginTransaction();

            Assert.That(unitOfWork.IsInTransaction);
            Assert.That(transaction, Is.Not.Null);
            mockContainer.VerifyAllExpectations();
        }
예제 #6
0
        public void Flush_Does_Nothing_When_A_TransactionHas_Already_Been_Started()
        {
            var mockContainer = MockRepository.GenerateMock <IObjectContainer>();
            var unitOfWork    = new Db4oUnitOfWork(mockContainer);

            unitOfWork.BeginTransaction();
            unitOfWork.Flush();
            mockContainer.AssertWasNotCalled(x => x.Commit());
            mockContainer.AssertWasNotCalled(x => x.Rollback());
            mockContainer.VerifyAllExpectations();
        }