Beispiel #1
0
        public void CreateDefault()
        {
            TestHelpers.EnsureLanguageIsValid();
            CruiseControlException exception = new CruiseControlException();

            Assert.AreEqual(string.Empty, exception.Message);
        }
Beispiel #2
0
        public void SerialisationWorksCorrectly()
        {
            var testMessage = "This is a test message";
            var error       = new CruiseControlException(testMessage);

            error.RunSerialisationTest();
        }
Beispiel #3
0
        public void SingleArgConstructorSetsMessage()
        {
            var testMessage = "This is a test message";
            var error       = new CruiseControlException(testMessage);

            Assert.AreEqual(testMessage, error.Message);
        }
Beispiel #4
0
        public void CreateWithMessage()
        {
            TestHelpers.EnsureLanguageIsValid();
            string message = "An error has occured";
            CruiseControlException exception = new CruiseControlException(message);

            Assert.AreEqual(message, exception.Message);
        }
Beispiel #5
0
        public void DoubleArgConstructorSetsMessageAndInner()
        {
            var testMessage = "This is a test message";
            var inner       = new Exception("Inner");
            var error       = new CruiseControlException(testMessage, inner);

            Assert.AreEqual(testMessage, error.Message);
            Assert.AreSame(inner, error.InnerException);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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.IsInstanceOfType(typeof(CruiseControlException), result);
            Assert.AreEqual(message, (result as CruiseControlException).Message);
        }
        public void ShouldGiveViewOfExceptionIfProxiedActionThowsException()
        {
            // Setup
            CruiseControlException e = new CruiseControlException("A nasty exception");

            actionMock.Setup(_action => _action.Execute(request)).Throws(e).Verifiable();

            velocityViewGeneratorMock.Setup(generator => generator.GenerateView("ActionException.vm", It.Is <Hashtable>(t => t.Count == 1 && t["exception"] == e))).
            Returns(errorResponse).Verifiable();

            // Execute & Verify
            Assert.AreEqual(errorResponse, exceptionCatchingAction.Execute(request));
            VerifyAll();
        }
        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();
        }
        // 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();
        }
Beispiel #11
0
        // publishers will need to log their own exceptions
        [Test] public void IfPublisherThrowsExceptionShouldStillSaveState()
        {
            mockLabeller.Setup(labeller => labeller.Generate(It.IsAny <IIntegrationResult>())).Returns("1.0").Verifiable();
            mockStateManager.Setup(_manager => _manager.HasPreviousState(ProjectName)).Returns(false).Verifiable();
            mockStateManager.Setup(_manager => _manager.SaveState(It.IsAny <IIntegrationResult>())).Verifiable();
            mockSourceControl.Setup(sourceControl => sourceControl.GetModifications(It.IsAny <IIntegrationResult>(), It.IsAny <IIntegrationResult>())).Returns(CreateModifications()).Verifiable();
            mockSourceControl.Setup(sourceControl => sourceControl.GetSource(It.IsAny <IIntegrationResult>())).Verifiable();
            mockSourceControl.Setup(sourceControl => sourceControl.LabelSourceControl(It.IsAny <IIntegrationResult>())).Verifiable();
            Exception expectedException = new CruiseControlException("expected exception");

            mockPublisher.Setup(publisher => publisher.Run(It.IsAny <IIntegrationResult>())).Throws(expectedException).Verifiable();
            mockTask.Setup(task => task.Run(It.IsAny <IntegrationResult>())).Callback <IIntegrationResult>(r => r.AddTaskResult("success")).Verifiable();

            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();
        }