public void CommitTransactionExceptionOccurred() { beginTransaction(); _transactionMock.ExpectAndThrow("Commit", new ApplicationException("Okay")); _connectionMock.Expect("Close"); _connectionMock.ExpectAndReturn("State", ConnectionState.Open); _transactionMock.Expect("Rollback"); try { _executionState.CommitTransaction(); Assert.Fail("should have thrown exception"); } catch (TransactionFailureException) { // just trap } _transactionMock.Verify(); _connectionMock.Verify(); }
public void ExecuteWithAnException() { _commandMock.Expect("Connection", _connection); _commandMock.ExpectAndThrow("ExecuteNonQuery", new ApplicationException("okay")); _commandMock.Expect("Connection", new IsNull()); _connectionMock.Strict = true; // no calls to connection. try { int recordCount = _executionState.Execute((IDbCommand)_commandMock.MockInstance); Assert.Fail("should be an exception here."); } catch (ApplicationException e) { Assert.AreEqual("okay", e.Message); } _commandMock.Verify(); _connectionMock.Verify(); }
public void ExecuteWithAnException() { _connectionMock.Expect("Open"); _commandMock.Expect("Connection", _connectionMock.MockInstance); _commandMock.ExpectAndThrow("ExecuteNonQuery", new ApplicationException("Okay")); _commandMock.Expect("Connection", new IsNull()); _connectionMock.Expect("Close"); try { _executionState.Execute((IDbCommand)_commandMock.MockInstance); Assert.Fail("Should have thrown the exception"); } catch (ApplicationException e) { Assert.AreEqual("Okay", e.Message); } _commandMock.Verify(); _connectionMock.Verify(); }
public void ShouldStillPublishResultsIfPrebuildThrowsException() { SetupPreambleExpections(); resultMock.ExpectAndReturn("ShouldRunBuild", true); resultMock.ExpectAndReturn("LastIntegrationStatus", IntegrationStatus.Success); targetMock.Expect("Activity", ProjectActivity.Building); sourceControlMock.Expect("GetSource", result); targetMock.ExpectAndThrow("Prebuild", new CruiseControlException("expected exception"), result); resultMock.Expect("ExceptionResult"); resultMock.Expect("MarkEndTime"); targetMock.Expect("Activity", ProjectActivity.Sleeping); resultMock.ExpectAndReturn("EndTime", endTime); resultMock.ExpectAndReturn("Status", IntegrationStatus.Exception); targetMock.Expect("PublishResults", result); resultManagerMock.Expect("FinishIntegration"); runner.Integrate(ModificationExistRequest()); mockery.Verify(); }
protected void ExpectToExecuteAndThrow() { mockProcessExecutor.ExpectAndThrow("Execute", new IOException(), new IsAnything()); }
[Test][ExpectedException(typeof(System.IO.IOException))] public void CallMethodTheThrowsException() { mock.ExpectAndThrow("boolReturn", new System.IO.IOException()); thingy.boolReturn(); }
public void ShouldHandleExceptionAccessingUrl() { mockHttpWrapper.ExpectAndThrow("GetLastModifiedTimeFor", new Exception("Uh-oh"), new Uri(DefaultUrl), DateTime.MinValue); Assert.IsNull(trigger.Fire(), "trigger.Fire()"); }