public void ExecuteNonQuery_WithError() { Exception exception = new Exception("TestException"); _innerCommandMock.Stub(mock => mock.CommandText).Return("commandText"); _innerCommandMock.Stub(mock => mock.Parameters).Return(CreateParameterCollection()); using (_mockRepository.Ordered()) { _extensionMock.QueryExecuting(Arg.Is(_connectionID), Arg.Is(_command.QueryID), Arg.Is("commandText"), CreateParametersArgumentExpectation()); _innerCommandMock.Expect(mock => mock.ExecuteNonQuery()).Throw(exception); _extensionMock.QueryError(_connectionID, _command.QueryID, exception); } _mockRepository.ReplayAll(); try { _command.ExecuteNonQuery(); Assert.Fail("No exception"); } catch (Exception ex) { Assert.That(ex, Is.SameAs(exception)); } _mockRepository.VerifyAll(); }
public void QueryError() { var queryID = Guid.NewGuid(); var ex = new Exception(); _extension.QueryError(_connectionID, queryID, ex); }
public void QueryError() { var connectionID = Guid.NewGuid(); var queryID = Guid.NewGuid(); Exception ex = new Exception(); _innerPersistenceListener1.Expect(mock => mock.QueryError(connectionID, queryID, ex)); _innerPersistenceListener2.Expect(mock => mock.QueryError(connectionID, queryID, ex)); _mockRepository.ReplayAll(); _extension.QueryError(connectionID, queryID, ex); _mockRepository.VerifyAll(); }
private T ExecuteWithProfiler <T> (Func <T> operation) { try { _persistenceExtension.QueryExecuting(_connectionID, _queryID, _command.CommandText, ConvertToDictionary(_command.Parameters)); var stopWatch = Stopwatch.StartNew(); T result = operation(); _persistenceExtension.QueryExecuted(_connectionID, _queryID, stopWatch.Elapsed); return(result); } catch (Exception ex) { _persistenceExtension.QueryError(_connectionID, _queryID, ex); throw; } }