Exemplo n.º 1
0
        protected IIntegrationResult IntegrationResult(DateTime start)
        {
            IntegrationResult successful = IntegrationResultMother.CreateSuccessful(start);

            successful.WorkingDirectory = DefaultWorkingDirectory;
            return(successful);
        }
Exemplo n.º 2
0
        public void ShouldClearMessagesAfterSuccessfulBuild()
        {
            mockStateManager.ExpectAndReturn("HasPreviousState", false, ProjectName);
            mockTrigger.ExpectAndReturn("NextBuild", DateTime.Now);
            mockPublisher.Expect("Run", new AddTaskResultConstraint());

            project.AddMessage(new Message("foo"));
            project.PublishResults(IntegrationResultMother.CreateSuccessful());
            ProjectStatus status = project.CreateProjectStatus(new ProjectIntegrator(project, queue));

            Assert.AreEqual(0, status.Messages.Length);
        }
Exemplo n.º 3
0
        public void ShouldClearMessagesAfterSuccessfulBuild()
        {
            mockStateManager.Setup(_manager => _manager.HasPreviousState(ProjectName)).Returns(false).Verifiable();
            mockTrigger.SetupGet(_trigger => _trigger.NextBuild).Returns(DateTime.Now).Verifiable();
            mockPublisher.Setup(publisher => publisher.Run(It.IsAny <IntegrationResult>())).Callback <IIntegrationResult>(r => r.AddTaskResult("success")).Verifiable();

            project.AddMessage(new Message("foo"));
            project.PublishResults(IntegrationResultMother.CreateSuccessful());
            ProjectStatus status = project.CreateProjectStatus(new ProjectIntegrator(project, queue));

            Assert.AreEqual(0, status.Messages.Length);
        }
Exemplo n.º 4
0
        public void StartNewIntegrationShouldCreateNewIntegrationResultAndProperlyPopulate()
        {
            ExpectToLoadState(IntegrationResultMother.CreateSuccessful("success"));

            IIntegrationResult result = manager.StartNewIntegration(ForceBuildRequest());

            Assert.AreEqual("project", result.ProjectName);
            Assert.AreEqual(@"c:\temp", result.WorkingDirectory);
            Assert.AreEqual(BuildCondition.ForceBuild, result.BuildCondition);
            Assert.AreEqual("success", result.Label);
            Assert.AreEqual(project.ArtifactDirectory, result.ArtifactDirectory);
            Assert.AreEqual(project.WebURL, result.ProjectUrl);
            Assert.AreEqual("success", result.LastSuccessfulIntegrationLabel);
            Assert.AreEqual(Source, result.IntegrationRequest.Source);
        }
Exemplo n.º 5
0
        public void RunningIntegrationWithNoModificationsShouldNotBuildOrPublish()
        {
            mockStateManager.ExpectAndReturn("HasPreviousState", true, ProjectName);
            mockStateManager.ExpectAndReturn("LoadState", IntegrationResultMother.CreateSuccessful(), ProjectName);
            mockSourceControl.ExpectAndReturn("GetModifications", new Modification[0], new IsAnything(), new IsAnything());             // return no modifications found
            mockPublisher.ExpectNoCall("Run", typeof(IntegrationResult));

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

            Assert.AreEqual(ProjectName, result.ProjectName);
            Assert.AreEqual(null, result.ExceptionResult);
            Assert.AreEqual(ProjectActivity.Sleeping, project.CurrentActivity);
            Assert.AreEqual(IntegrationStatus.Unknown, result.Status);
            Assert.IsNotNull(project.CurrentResult);
            //Assert.AreEqual(IntegrationResult.InitialLabel, result.Label);
            AssertFalse("unexpected modifications were returned", result.HasModifications());
            AssertEqualArrays(new Modification[0], result.Modifications);
            Assert.AreEqual(string.Empty, result.TaskOutput, "no output is expected as builder is not called");
            //			Assert.IsTrue(result.EndTime >= result.StartTime);
            VerifyAll();
        }
        public void ShouldNotResetLabelIfGetModificationsThrowsException()
        {
            IMock mockSourceControl = new DynamicMock(typeof(ISourceControl));

            mockSourceControl.ExpectAndThrow("GetModifications", new Exception("doh!"), new IsAnything(), new IsAnything());
            mockSourceControl.ExpectAndReturn("GetModifications", new Modification[] { new Modification() }, new IsAnything(), new IsAnything());

            StateManagerStub stateManagerStub = new StateManagerStub();

            stateManagerStub.SaveState(IntegrationResultMother.CreateSuccessful("10"));

            Project project = new Project();

            project.Name          = "test";
            project.SourceControl = (ISourceControl)mockSourceControl.MockInstance;
            project.StateManager  = stateManagerStub;
            try { project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null)); }
            catch (Exception) { }

            project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null));
            Assert.AreEqual(IntegrationStatus.Success, project.CurrentResult.Status);
            Assert.AreEqual("11", project.CurrentResult.Label);
        }
        public void ShouldNotResetLabelIfGetModificationsThrowsException()
        {
            var          mockSourceControl = new Mock <ISourceControl>();
            MockSequence sequence          = new MockSequence();

            mockSourceControl.InSequence(sequence).Setup(sourceControl => sourceControl.GetModifications(It.IsAny <IIntegrationResult>(), It.IsAny <IIntegrationResult>())).Throws(new Exception("doh!")).Verifiable();
            mockSourceControl.InSequence(sequence).Setup(sourceControl => sourceControl.GetModifications(It.IsAny <IIntegrationResult>(), It.IsAny <IIntegrationResult>())).Returns(new Modification[] { new Modification() }).Verifiable();

            StateManagerStub stateManagerStub = new StateManagerStub();

            stateManagerStub.SaveState(IntegrationResultMother.CreateSuccessful("10"));

            Project project = new Project();

            project.Name          = "test";
            project.SourceControl = (ISourceControl)mockSourceControl.Object;
            project.StateManager  = stateManagerStub;
            try { project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null)); }
            catch (Exception) { }

            project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null));
            Assert.AreEqual(IntegrationStatus.Success, project.CurrentResult.Status);
            Assert.AreEqual("11", project.CurrentResult.Label);
        }
Exemplo n.º 8
0
        public void RunningIntegrationWithNoModificationsShouldNotBuildOrPublish()
        {
            mockStateManager.Setup(_manager => _manager.HasPreviousState(ProjectName)).Returns(true).Verifiable();
            mockStateManager.Setup(_manager => _manager.LoadState(ProjectName)).Returns(IntegrationResultMother.CreateSuccessful()).Verifiable();
            mockSourceControl.Setup(sourceControl => sourceControl.GetModifications(It.IsAny <IIntegrationResult>(), It.IsAny <IIntegrationResult>())).Returns(new Modification[0]).Verifiable();           // return no modifications found

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

            Assert.AreEqual(ProjectName, result.ProjectName);
            Assert.AreEqual(null, result.ExceptionResult);
            Assert.AreEqual(ProjectActivity.Sleeping, project.CurrentActivity);
            Assert.AreEqual(IntegrationStatus.Unknown, result.Status);
            Assert.IsNotNull(project.CurrentResult);
            //Assert.AreEqual(IntegrationResult.InitialLabel, result.Label);
            AssertFalse("unexpected modifications were returned", result.HasModifications());
            AssertEqualArrays(new Modification[0], result.Modifications);
            Assert.AreEqual(string.Empty, result.TaskOutput, "no output is expected as builder is not called");
            //			Assert.IsTrue(result.EndTime >= result.StartTime);
            mockPublisher.Verify(publisher => publisher.Run(It.IsAny <IntegrationResult>()), Times.Never);
            VerifyAll();
        }