public void Rollback_RunTranactionAndRoleback_RollbackOnTheUnderlyingObjectIsCalled() { var underlyingTrans = A.Fake<IDbTransaction>(); var connection = new FakeConnection(underlyingTrans); var dataSource = A.Fake<IDataSource>(); A.CallTo(() => dataSource.OpenConnection()).Returns(connection); using(var trans = TransactionFactory.BeginTransaction(dataSource, IsolationLevel.Chaos)) { var myCommand = dataSource.CreateSPCommand("exec storedprocedure", trans); dataSource.ExecuteDataSet(myCommand); dataSource.ExecuteNonQuery("select * from table", CommandType.Text, trans); trans.Rollback(); A.CallTo(() => underlyingTrans.Rollback()).MustHaveHappened(Repeated.Exactly.Once); Assert.AreEqual(IsolationLevel.Chaos, trans.IsolationLevel); } }
public void Rollback_RunTranactionAndRoleback_RollbackOnTheUnderlyingObjectIsCalled() { var underlyingTrans = A.Fake <IDbTransaction>(); var connection = new FakeConnection(underlyingTrans); var dataSource = A.Fake <IDataSource>(); A.CallTo(() => dataSource.OpenConnection()).Returns(connection); using (var trans = TransactionFactory.BeginTransaction(dataSource, IsolationLevel.Chaos)) { var myCommand = dataSource.CreateSPCommand("exec storedprocedure", trans); dataSource.ExecuteDataSet(myCommand); dataSource.ExecuteNonQuery("select * from table", CommandType.Text, trans); trans.Rollback(); A.CallTo(() => underlyingTrans.Rollback()).MustHaveHappened(Repeated.Exactly.Once); Assert.AreEqual(IsolationLevel.Chaos, trans.IsolationLevel); } }