Ejemplo n.º 1
0
        public void ShouldSetTransactionToInnerCommand()
        {
            MockDbCommand      dbCommandMock   = new MockDbCommand();
            Mock <ISyncPolicy> retryPolicyMock = new Mock <ISyncPolicy>();
            var commandWrapper = new ReliableDbCommandWrapper(dbCommandMock, retryPolicyMock.Object);
            MockDbTransaction mockDbTransaction = new MockDbTransaction();

            commandWrapper.Transaction = mockDbTransaction;
            Assert.Equal(mockDbTransaction, dbCommandMock.Transaction);
        }
Ejemplo n.º 2
0
        public void ShouldReadTransactionFromInnerCommandAndWrap()
        {
            MockDbCommand      dbCommandMock   = new MockDbCommand();
            Mock <ISyncPolicy> retryPolicyMock = new Mock <ISyncPolicy>();
            var commandWrapper = new ReliableDbCommandWrapper(dbCommandMock, retryPolicyMock.Object);
            MockDbTransaction mockDbTransaction = new MockDbTransaction();

            dbCommandMock.Transaction = mockDbTransaction;
            Assert.True(commandWrapper.Transaction is ReliableDbTransactionWrapper);
            Assert.Equal(mockDbTransaction, ((ReliableDbTransactionWrapper)commandWrapper.Transaction).InnerTransaction);
        }
Ejemplo n.º 3
0
        public void ShouldDisposeInnerTransaction()
        {
            Mock <DbConnection>         dbConnectionMock  = new Mock <DbConnection>();
            MockDbTransaction           dbTransactionMock = new MockDbTransaction();
            Mock <ISyncPolicy>          retryPolicyMock   = new Mock <ISyncPolicy>();
            ReliableDbConnectionWrapper connectionWrapper = new ReliableDbConnectionWrapper(dbConnectionMock.Object, retryPolicyMock.Object);

            var transactionWrapper = new ReliableDbTransactionWrapper(dbTransactionMock, connectionWrapper, retryPolicyMock.Object);

            transactionWrapper.Dispose();
            Assert.Equal(1, dbTransactionMock.DisposalCount);
        }