public void BeganTransaction_does_not_record_transaction_if_connection_does_not_match() { var context = Core.Objects.MockHelper.CreateMockObjectContext<object>(); var handler = new DefaultTransactionHandler(); handler.Initialize(context); var mockTransaction = new Mock<DbTransaction>().Object; var beginTransactionInterceptionContext = new BeginTransactionInterceptionContext(); beginTransactionInterceptionContext.Result = mockTransaction; handler.BeganTransaction(new Mock<DbConnection>().Object, beginTransactionInterceptionContext); var interceptionContext = new DbTransactionInterceptionContext(); interceptionContext.Exception = new Exception(); handler.Committed(mockTransaction, interceptionContext); Assert.IsNotType<CommitFailedException>(interceptionContext.Exception); }
public void Commited_wraps_exceptions_for_known_transactions() { var context = Core.Objects.MockHelper.CreateMockObjectContext<object>(); var handler = new DefaultTransactionHandler(); handler.Initialize(context); var mockTransaction = new Mock<DbTransaction>().Object; var beginTransactionInterceptionContext = new BeginTransactionInterceptionContext(); beginTransactionInterceptionContext.Result = mockTransaction; handler.BeganTransaction(handler.Connection, beginTransactionInterceptionContext); var interceptionContext = new DbTransactionInterceptionContext().WithConnection(handler.Connection); interceptionContext.Exception = new Exception(); handler.Committed(mockTransaction, interceptionContext); Assert.IsType<CommitFailedException>(interceptionContext.Exception); }
public void BeganTransaction_does_not_record_transaction_if_connection_does_not_match() { var context = Core.Objects.MockHelper.CreateMockObjectContext <object>(); var handler = new DefaultTransactionHandler(); handler.Initialize(context); var mockTransaction = new Mock <DbTransaction>().Object; var beginTransactionInterceptionContext = new BeginTransactionInterceptionContext(); beginTransactionInterceptionContext.Result = mockTransaction; handler.BeganTransaction(new Mock <DbConnection>().Object, beginTransactionInterceptionContext); var interceptionContext = new DbTransactionInterceptionContext(); interceptionContext.Exception = new Exception(); handler.Committed(mockTransaction, interceptionContext); Assert.IsNotType <CommitFailedException>(interceptionContext.Exception); }
public void Commited_wraps_exceptions_for_known_transactions() { var context = Core.Objects.MockHelper.CreateMockObjectContext <object>(); var handler = new DefaultTransactionHandler(); handler.Initialize(context); var mockTransaction = new Mock <DbTransaction>().Object; var beginTransactionInterceptionContext = new BeginTransactionInterceptionContext(); beginTransactionInterceptionContext.Result = mockTransaction; handler.BeganTransaction(handler.Connection, beginTransactionInterceptionContext); var interceptionContext = new DbTransactionInterceptionContext().WithConnection(handler.Connection); interceptionContext.Exception = new Exception(); handler.Committed(mockTransaction, interceptionContext); Assert.IsType <CommitFailedException>(interceptionContext.Exception); }