Example #1
0
        public void ExecuteRetrieval_Error_BindsSession()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            NotLogged(() => sut.Execute <int>(() => { throw new Exception(); }));

            sut.SessionWasBound.ShouldBeTrue();
        }
Example #2
0
        public void BatchExecute_Error_DoesNotCommitTransaction()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            NotLogged(() => sut.BatchExecute(s => { throw new Exception(); }));

            _transactionMock.Verify(tx => tx.Commit(), Times.Never());
        }
Example #3
0
        public void ExecuteRetrieval_NoError_BindsSession()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            sut.Execute(() => 1);

            sut.SessionWasBound.ShouldBeTrue();
        }
Example #4
0
        public void BatchExecute_Error_RollsBackTransaction()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            NotLogged(() => sut.BatchExecute(s => { throw new Exception(); }));

            _transactionMock.Verify(tx => tx.Rollback());
        }
Example #5
0
        public void BatchExecute_NoError_CommitsTransaction()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            sut.BatchExecute(s => { });

            _transactionMock.Verify(tx => tx.Commit());
        }
Example #6
0
        public void Execute_NoError_UnbindsSession()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            sut.Execute(() => { });

            sut.SessionWasUnbound.ShouldBeTrue();
        }
Example #7
0
        public void Execute_Always_BeginsTransactionUsingSessionFromSessionFactoryManager()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            sut.Execute(() => { });

            _sessionStub.Verify(s => s.BeginTransaction());
        }
Example #8
0
        public void Execute_Always_ExecutesAction()
        {
            var  sut = new TransactionManagerMock(_sessionFactoryStub.Object);
            bool actionWasExecuted = false;

            sut.Execute(() => actionWasExecuted = true);

            actionWasExecuted.ShouldBeTrue();
        }
Example #9
0
        public void BatchExecute_Always_OpensStatelessSession()
        {
            var sessionFactoryMock = _sessionFactoryStub;
            var sut = new TransactionManagerMock(sessionFactoryMock.Object);

            sut.BatchExecute(s => { });

            sessionFactoryMock.Verify(sf => sf.OpenStatelessSession());
        }
Example #10
0
        public void ExecuteRetrieval_Error_ReturnsDefaultOfTResult()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            int result = 1;

            NotLogged(() => result = sut.Execute <int>(() => { throw new Exception(); }));

            result.ShouldBeEqualTo(0);
        }
Example #11
0
        public void ExecuteRetrieval_NoError_ReturnsResultOfAction()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            const int resultOfAction = 1;
            int       result         = 0;

            NotLogged(() => result = sut.Execute(() => resultOfAction));

            result.ShouldBeEqualTo(resultOfAction);
        }