public void CreateWithMessage()
 {
     TestHelpers.EnsureLanguageIsValid();
     string message = "An error has occured";
     CruiseControlException exception = new CruiseControlException(message);
     Assert.AreEqual(message, exception.Message);
 }
 public void CreateWithMessageAndException()
 {
     TestHelpers.EnsureLanguageIsValid();
     string message = "An error has occured";
     Exception innerException = new Exception("An inner exception");
     CruiseControlException exception = new CruiseControlException(message, innerException);
     Assert.AreEqual(message, exception.Message);
     Assert.AreEqual(innerException, exception.InnerException);
 }
 public void PassThroughSerialisation()
 {
     TestHelpers.EnsureLanguageIsValid();
     string message = "An error has occured";
     CruiseControlException exception = new CruiseControlException(message);
     object result = TestHelpers.RunSerialisationTest(exception);
     Assert.IsNotNull(result);
     Assert.That(result, Is.InstanceOf<CruiseControlException>());
     Assert.AreEqual(message, (result as CruiseControlException).Message);
 }
		public void ShouldGiveViewOfExceptionIfProxiedActionThowsException()
		{
			// Setup
			CruiseControlException e = new CruiseControlException("A nasty exception");
			actionMock.ExpectAndThrow("Execute", e, request);

			Hashtable expectedContext = new Hashtable();
			expectedContext["exception"] = e;
			velocityViewGeneratorMock.ExpectAndReturn("GenerateView", errorResponse, "ActionException.vm", new HashtableConstraint(expectedContext));

			// Execute & Verify
			Assert.AreEqual(errorResponse, exceptionCatchingAction.Execute(request));
			VerifyAll();
		}
Ejemplo n.º 5
0
		// publishers will need to log their own exceptions
		[Test] public void IfPublisherThrowsExceptionShouldStillSaveState()
		{
			mockLabeller.ExpectAndReturn("Generate", "1.0", new IsAnything());
			mockStateManager.ExpectAndReturn("HasPreviousState", false, ProjectName);
			mockStateManager.Expect("SaveState", new IsAnything());
			mockSourceControl.ExpectAndReturn("GetModifications", CreateModifications(), new IsAnything(), new IsAnything());
			mockSourceControl.Expect("GetSource", new IsAnything());
			mockSourceControl.Expect("LabelSourceControl", new IsAnything());
			Exception expectedException = new CruiseControlException("expected exception");
			mockPublisher.ExpectAndThrow("Run", expectedException, new IsAnything());
			mockTask.Expect("Run", new AddTaskResultConstraint());

			IIntegrationResult results = project.Integrate(ModificationExistRequest());

			// failure to save the integration result will register as a failed project
			Assert.AreEqual(results, project.CurrentResult, "new integration result has not been set to the last integration result");
			Assert.IsNotNull(results.EndTime);
			VerifyAll();
		}
 public void CreateDefault()
 {
     TestHelpers.EnsureLanguageIsValid();
     CruiseControlException exception = new CruiseControlException();
     Assert.AreEqual(string.Empty, exception.Message);
 }
Ejemplo n.º 7
0
        public void RunWhereFirstTaskThrowsException()
        {
            Workflow project = new Workflow();
            Exception ex = new CruiseControlException("foo");
            IMock taskMock1 = new DynamicMock(typeof (ITask));
            taskMock1.ExpectAndThrow("Run", ex, new NotNull());

            IMock taskMock2 = new DynamicMock(typeof (ITask));
            taskMock2.Expect("Run", new NotNull());

            project.Tasks.Add(taskMock1.MockInstance);
            project.Tasks.Add(taskMock2.MockInstance);

            IIntegrationResult result = project.Integrate(ModificationExistRequest());

            taskMock1.Verify();
            taskMock2.Verify();
            Assert.AreEqual(IntegrationStatus.Exception, result.Status);
            Assert.AreEqual(ex, result.ExceptionResult);
        }