Пример #1
0
        public void BatchExecute_Error_RollsBackTransaction()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

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

            _transactionMock.Verify(tx => tx.Rollback());
        }
Пример #2
0
        public void BatchExecute_NoError_CommitsTransaction()
        {
            var sut = new TransactionManagerMock(_sessionFactoryStub.Object);

            sut.BatchExecute(s => { });

            _transactionMock.Verify(tx => tx.Commit());
        }
Пример #3
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());
        }
Пример #4
0
        public void BatchExecute_Always_ExecutesAction()
        {
            var  sut = new TransactionManagerMock(_sessionFactoryStub.Object);
            bool actionWasExecuted = false;

            sut.BatchExecute(s => actionWasExecuted = true);

            actionWasExecuted.ShouldBeTrue();
        }
Пример #5
0
        public void BatchExecute_Always_OpensStatelessSession()
        {
            var sessionFactoryMock = _sessionFactoryStub;
            var sut = new TransactionManagerMock(sessionFactoryMock.Object);

            sut.BatchExecute(s => { });

            sessionFactoryMock.Verify(sf => sf.OpenStatelessSession());
        }