コード例 #1
0
        public void SuccessfulIntegrationShouldResetFailedTasksOnNextIntegration()
        {
            IIntegrationResult result1 = IntegrationResultMother.CreateFailed();

            result1.FailureTasks.Add("task1");
            ExpectToLoadState(result1);

            IIntegrationResult result2 = manager.StartNewIntegration(ModificationExistRequest());

            Assert.AreEqual(0, result2.FailureTasks.Count);

            Modification modification = new Modification();

            modification.UserName = "******";
            result2.Modifications = new Modification[] { modification };
            result2.Status        = IntegrationStatus.Success;
            result2.FailureTasks.Add("task2");
            mockStateManager.Expect("SaveState", result2);
            manager.FinishIntegration();
            Assert.AreEqual(1, result2.FailureTasks.Count);
            Assert.AreEqual("task2", result2.FailureTasks[0]);

            IIntegrationResult result3 = manager.StartNewIntegration(ModificationExistRequest());

            Assert.AreEqual(0, result3.FailureTasks.Count);
        }
コード例 #2
0
        protected IIntegrationResult IntegrationResult(DateTime start)
        {
            IntegrationResult successful = IntegrationResultMother.CreateSuccessful(start);

            successful.WorkingDirectory = DefaultWorkingDirectory;
            return(successful);
        }
コード例 #3
0
        public IntegrationResult SuccessfulResult(string previousLabel)
        {
            var result =
                IntegrationResultMother.Create(new IntegrationSummary(IntegrationStatus.Success, previousLabel, previousLabel,
                                                                      DateTime.MinValue));

            result.Status = IntegrationStatus.Success;
            return(result);
        }
コード例 #4
0
        public void DoNotClearMessagesAfterFailedBuild()
        {
            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.CreateFailed());
            ProjectStatus status = project.CreateProjectStatus(new ProjectIntegrator(project, queue));

            Assert.AreEqual(2, status.Messages.Length);
        }
コード例 #5
0
        public void DoNotClearMessagesAfterFailedBuild()
        {
            mockStateManager.ExpectAndReturn("HasPreviousState", false, ProjectName);
            mockTrigger.ExpectAndReturn("NextBuild", DateTime.Now);
            mockPublisher.Expect("Run", new AddTaskResultConstraint());

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

            Assert.AreEqual(2, status.Messages.Length);
        }
コード例 #6
0
        public void ShouldStopBuildIfTaskFails()
        {
            IntegrationResult result = IntegrationResultMother.CreateFailed();

            mockTask.Setup(task => task.Run(result)).Verifiable();

            var secondTask = new Mock <ITask>();

            project.Tasks = new ITask[] { (ITask)mockTask.Object, (ITask)secondTask.Object };
            project.Run(result);
            VerifyAll();
            secondTask.Verify(task => task.Run(It.IsAny <IntegrationResult>()), Times.Never);
        }
コード例 #7
0
        public void ShouldStopBuildIfTaskFails()
        {
            IntegrationResult result = IntegrationResultMother.CreateFailed();

            mockTask.Expect("Run", result);

            IMock secondTask = new DynamicMock(typeof(ITask));

            secondTask.ExpectNoCall("Run", typeof(IntegrationResult));

            project.Tasks = new ITask[] { (ITask)mockTask.MockInstance, (ITask)secondTask.MockInstance };
            project.Run(result);
            VerifyAll();
            secondTask.Verify();
        }
コード例 #8
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);
        }
コード例 #9
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();
        }
コード例 #10
0
        public void FailedIntegrationShouldAddModificationUsersToFailedUsers()
        {
            IIntegrationResult lastResult = IntegrationResultMother.CreateFailed();

            lastResult.FailureUsers.Add("user1");
            ExpectToLoadState(lastResult);

            IIntegrationResult newResult = manager.StartNewIntegration(ModificationExistRequest());

            Assert.AreEqual(1, newResult.FailureUsers.Count, "Mismatched count of inherited FailureUsers");

            Modification modification = new Modification();

            modification.UserName   = "******";
            newResult.Modifications = new Modification[] { modification };
            newResult.Status        = IntegrationStatus.Failure;
            mockStateManager.Expect("SaveState", newResult);
            manager.FinishIntegration();

            Assert.AreEqual(2, newResult.FailureUsers.Count, "Mismatched count of resulting FailureUsers");
        }
コード例 #11
0
        public void FailedIntegrationShouldResetFailedTasksOnNextIntegration()
        {
            IIntegrationResult lastResult = IntegrationResultMother.CreateFailed();

            lastResult.FailureTasks.Add("task1");
            ExpectToLoadState(lastResult);

            IIntegrationResult newResult = manager.StartNewIntegration(ModificationExistRequest());

            Assert.AreEqual(0, newResult.FailureTasks.Count, "Mismatched count of inherited FailureTasks");

            Modification modification = new Modification();

            modification.UserName   = "******";
            newResult.Modifications = new Modification[] { modification };
            newResult.Status        = IntegrationStatus.Failure;
            newResult.FailureTasks.Add("task2");
            mockStateManager.Setup(_manager => _manager.SaveState(newResult)).Verifiable();
            manager.FinishIntegration();

            Assert.AreEqual(1, newResult.FailureTasks.Count, "Mismatched count of resulting FailureTasks");
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public void SuccessfulIntegrationShouldClearFailedUsersOnNextIntegration()
        {
            IIntegrationResult result1 = IntegrationResultMother.CreateFailed();

            result1.FailureUsers.Add("user1");
            ExpectToLoadState(result1);

            IIntegrationResult result2 = manager.StartNewIntegration(ModificationExistRequest());

            Assert.AreEqual(1, result2.FailureUsers.Count);

            Modification modification = new Modification();

            modification.UserName = "******";
            result2.Modifications = new Modification[] { modification };
            result2.Status        = IntegrationStatus.Success;
            mockStateManager.Setup(_manager => _manager.SaveState(result2)).Verifiable();
            manager.FinishIntegration();
            Assert.AreEqual(1, result2.FailureUsers.Count);

            IIntegrationResult result3 = manager.StartNewIntegration(ModificationExistRequest());

            Assert.AreEqual(0, result3.FailureUsers.Count);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
 public IntegrationResult InitialIntegrationResult()
 {
     return(IntegrationResultMother.CreateInitial());
 }
コード例 #16
0
 public IntegrationResult FailedResult(string previousLabel, string lastSuccessfulLabel)
 {
     return(IntegrationResultMother.Create(new IntegrationSummary(IntegrationStatus.Failure, previousLabel, lastSuccessfulLabel, DateTime.MinValue)));
 }
コード例 #17
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();
        }