Ejemplo n.º 1
0
        public void WhenTheStateOfTheProjectChangesTheStatusEntriesOnTheListViewItemAreUpdated()
        {
            StubProjectMonitor projectMonitor = new StubProjectMonitor("projectName");

            projectMonitor.ProjectState  = ProjectState.Building;
            projectMonitor.ProjectStatus = null;
            projectMonitor.Configuration = new CCTrayProject("http://somewhere", "projectName");

            ProjectStatusListViewItemAdaptor adaptor = new ProjectStatusListViewItemAdaptor(detailStringFormatter);
            ListViewItem item = adaptor.Create(projectMonitor);

            Assert.AreEqual(10, item.SubItems.Count);
            ListViewItem.ListViewSubItem activity = item.SubItems[3];
            ListViewItem.ListViewSubItem label    = item.SubItems[5];

            Assert.AreEqual("", activity.Text);
            Assert.AreEqual("", label.Text);

            ProjectStatus status = ProjectStatusFixture.New(ProjectActivity.Sleeping, "lastLabel");

            projectMonitor.ProjectStatus = status;

            projectMonitor.OnPolled(new MonitorPolledEventArgs(projectMonitor));

            Assert.AreEqual("Sleeping", activity.Text);
            Assert.AreEqual("lastLabel", label.Text);
        }
        public void ShouldCorrectlyReportEstimatedTimeWhenANewBuildStartsDuringThePollInterval()
        {
            ProjectStatus firstBuildStatus =
                ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building, new DateTime(2007, 1, 1, 0, 0, 0));

            mockProjectManager.SetupGet(_manager => _manager.ProjectName).Returns(PROJECT_NAME).Verifiable();
            mockServerMonitor.Setup(_monitor => _monitor.GetProjectStatus(PROJECT_NAME)).Returns(firstBuildStatus).Verifiable();
            dateTimeProvider.SetNow(new DateTime(2007, 1, 1, 1, 0, 0));
            monitor.Poll();

            ProjectStatus secondBuildStatus =
                ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building, new DateTime(2007, 1, 1, 2, 0, 0));

            mockProjectManager.SetupGet(_manager => _manager.ProjectName).Returns(PROJECT_NAME).Verifiable();
            mockServerMonitor.Setup(_monitor => _monitor.GetProjectStatus(PROJECT_NAME)).Returns(secondBuildStatus).Verifiable();
            dateTimeProvider.SetNow(new DateTime(2007, 1, 1, 3, 0, 0));
            monitor.Poll();

            ProjectStatus thirdBuildStatus =
                ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building, new DateTime(2007, 1, 1, 4, 0, 0));

            mockProjectManager.SetupGet(_manager => _manager.ProjectName).Returns(PROJECT_NAME).Verifiable();
            mockServerMonitor.Setup(_monitor => _monitor.GetProjectStatus(PROJECT_NAME)).Returns(thirdBuildStatus).Verifiable();
            dateTimeProvider.SetNow(new DateTime(2007, 1, 1, 5, 0, 0));
            monitor.Poll();

            Assert.AreEqual(new TimeSpan(2, 0, 0), monitor.EstimatedTimeRemainingOnCurrentBuild);
        }
Ejemplo n.º 3
0
        public void LatestBuildWasSuccessfulIfNewProjectStatusIsSuccess()
        {
            ProjectStatus        lastProjectStatus    = ProjectStatusFixture.New(IntegrationStatus.Failure, new DateTime(2007, 1, 1));
            ProjectStatus        newProjectStatus     = ProjectStatusFixture.New(IntegrationStatus.Success, new DateTime(2007, 1, 2));
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(lastProjectStatus, newProjectStatus);

            Assert.IsTrue(pollIntervalReporter.WasLatestBuildSuccessful);
        }
Ejemplo n.º 4
0
        public void BuildCompletedDuringPollIntervalIfLastBuildDateChanged()
        {
            ProjectStatus        lastProjectStatus    = ProjectStatusFixture.New(IntegrationStatus.Success, new DateTime(2007, 1, 1));
            ProjectStatus        newProjectStatus     = ProjectStatusFixture.New(IntegrationStatus.Success, new DateTime(2007, 1, 2));
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(lastProjectStatus, newProjectStatus);

            Assert.IsTrue(pollIntervalReporter.IsAnotherBuildComplete);
        }
Ejemplo n.º 5
0
        public void FailureThenSuccessMeansBuildIsFixed()
        {
            ProjectStatus        lastProjectStatus    = ProjectStatusFixture.New("last failed", IntegrationStatus.Failure);
            ProjectStatus        newProjectStatus     = ProjectStatusFixture.New("new success", IntegrationStatus.Success);
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(lastProjectStatus, newProjectStatus);

            Assert.AreEqual(BuildTransition.Fixed, pollIntervalReporter.BuildTransition);
        }
Ejemplo n.º 6
0
        public void SuccessThenFailureMeansBuildIsBroken()
        {
            ProjectStatus        lastProjectStatus    = ProjectStatusFixture.New("last success", IntegrationStatus.Success);
            ProjectStatus        newProjectStatus     = ProjectStatusFixture.New("new failed", IntegrationStatus.Failure);
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(lastProjectStatus, newProjectStatus);

            Assert.AreEqual(BuildTransition.Broken, pollIntervalReporter.BuildTransition);
        }
Ejemplo n.º 7
0
        public void TwoFailuresMeansBuildIsStillFailing()
        {
            ProjectStatus        lastProjectStatus    = ProjectStatusFixture.New("last failed", IntegrationStatus.Failure);
            ProjectStatus        newProjectStatus     = ProjectStatusFixture.New("new failed", IntegrationStatus.Failure);
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(lastProjectStatus, newProjectStatus);

            Assert.AreEqual(BuildTransition.StillFailing, pollIntervalReporter.BuildTransition);
        }
Ejemplo n.º 8
0
        public void TwoSuccessesMeansBuildIsStillSuccessful()
        {
            ProjectStatus        lastProjectStatus    = ProjectStatusFixture.New("last successful", IntegrationStatus.Success);
            ProjectStatus        newProjectStatus     = ProjectStatusFixture.New("new successful", IntegrationStatus.Success);
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(lastProjectStatus, newProjectStatus);

            Assert.AreEqual(BuildTransition.StillSuccessful, pollIntervalReporter.BuildTransition);
        }
Ejemplo n.º 9
0
        public void CallingLatestStatusMessageWhenThereAreNoneIsSafe()
        {
            ProjectStatus newProjectStatus = ProjectStatusFixture.New("test project");

            newProjectStatus.Messages = new Message[] {};
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(newProjectStatus, newProjectStatus);

            Assert.AreEqual(new Message("").ToString(), pollIntervalReporter.AllStatusMessages.ToString());
        }
Ejemplo n.º 10
0
        public void BuildStartedIfStatusChangedToBuilding()
        {
            ProjectStatus oldProjectStatus = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);
            ProjectStatus newProjectStatus = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building);

            bool result = new PollIntervalReporter(oldProjectStatus, newProjectStatus).HasNewBuildStarted;

            Assert.IsTrue(result);
        }
        private void AssertIntegrationStateReturned(IntegrationStatus integrationStatus)
        {
            ProjectStatus status = ProjectStatusFixture.New(integrationStatus, ProjectActivity.CheckingModifications);

            mockProjectManager.SetupGet(_manager => _manager.ProjectName).Returns(PROJECT_NAME).Verifiable();
            mockServerMonitor.Setup(_monitor => _monitor.GetProjectStatus(PROJECT_NAME)).Returns(status).Verifiable();

            monitor.Poll();

            Assert.AreEqual(integrationStatus, monitor.IntegrationStatus);
        }
Ejemplo n.º 12
0
        private void AssertIntegrationStateReturned(IntegrationStatus integrationStatus)
        {
            ProjectStatus status = ProjectStatusFixture.New(integrationStatus, ProjectActivity.CheckingModifications);

            mockProjectManager.ExpectAndReturn("ProjectName", PROJECT_NAME);
            mockServerMonitor.ExpectAndReturn("GetProjectStatus", status, PROJECT_NAME);

            monitor.Poll();

            Assert.AreEqual(integrationStatus, monitor.IntegrationStatus);
        }
Ejemplo n.º 13
0
        public void MessagesUpdatedIfNewStatusHasMoreMessagesThanOld()
        {
            ProjectStatus oldProjectStatus = ProjectStatusFixture.New("test project");

            oldProjectStatus.Messages = new Message[] { new Message("message") };
            ProjectStatus newProjectStatus = ProjectStatusFixture.New("test project");

            newProjectStatus.Messages = new Message[] { new Message("message"), new Message("another message") };

            Assert.IsTrue(new PollIntervalReporter(oldProjectStatus, newProjectStatus).WasNewStatusMessagesReceived);
        }
        public void SummaryStatusStringReturnsEmptyStringWhenTheStateIsSuccess()
        {
            ProjectStatus status = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);

            mockProjectManager.SetupGet(_manager => _manager.ProjectName).Returns(PROJECT_NAME).Verifiable();
            mockServerMonitor.Setup(_monitor => _monitor.GetProjectStatus(PROJECT_NAME)).Returns(status).Verifiable();

            monitor.Poll();

            Assert.AreEqual(string.Empty, monitor.SummaryStatusString);
        }
Ejemplo n.º 15
0
        public void BuildStartedIfLastBuildDateHasChangedAndStatusRemainedBuilding()
        {
            ProjectStatus oldProjectStatus =
                ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building, new DateTime(2007, 1, 1));
            ProjectStatus newProjectStatus =
                ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building, new DateTime(2007, 1, 2));

            bool result = new PollIntervalReporter(oldProjectStatus, newProjectStatus).HasNewBuildStarted;

            Assert.IsTrue(result);
        }
Ejemplo n.º 16
0
        public void SummaryStatusStringReturnsEmptyStringWhenTheStateIsSuccess()
        {
            ProjectStatus status = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);

            mockProjectManager.ExpectAndReturn("ProjectName", PROJECT_NAME);
            mockServerMonitor.ExpectAndReturn("GetProjectStatus", status, PROJECT_NAME);

            monitor.Poll();

            Assert.AreEqual(string.Empty, monitor.SummaryStatusString);
        }
        public void GenerateXmlContentForSpecifiedProject()
        {
            ProjectStatusOnServer status  = new ProjectStatusOnServer(ProjectStatusFixture.New("wrong"), serverSpecifier);
            ProjectStatusOnServer status2 = new ProjectStatusOnServer(ProjectStatusFixture.New("test"), serverSpecifier);

            mockFarmService.Setup(service => service.GetProjectStatusListAndCaptureExceptions(null)).Returns(ProjectStatusList(status, status2)).Verifiable();

            IResponse response = report.Execute((ICruiseRequest)mockRequest.Object);

            Assert.That(response, Is.InstanceOf <XmlFragmentResponse>());
            string xml = ((XmlFragmentResponse)response).ResponseFragment;

            XPathAssert.Matches(XPathAssert.LoadAsDocument(xml), "/CruiseControl/Projects/Project/@name", "test");
        }
Ejemplo n.º 18
0
        public void GenerateXmlContentForSpecifiedProject()
        {
            ProjectStatusOnServer status  = new ProjectStatusOnServer(ProjectStatusFixture.New("wrong"), serverSpecifier);
            ProjectStatusOnServer status2 = new ProjectStatusOnServer(ProjectStatusFixture.New("test"), serverSpecifier);

            mockFarmService.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions", ProjectStatusList(status, status2), null);

            IResponse response = report.Execute((ICruiseRequest)mockRequest.MockInstance);

            Assert.IsInstanceOfType(typeof(XmlFragmentResponse), response);
            string xml = ((XmlFragmentResponse)response).ResponseFragment;

            XPathAssert.Matches(XPathAssert.LoadAsDocument(xml), "/CruiseControl/Projects/Project/@name", "test");
        }
Ejemplo n.º 19
0
        public void NoBuildIfLastBuildDateIsSameAndStatusIsSame()
        {
            DateTime lastBuildDate = new DateTime(2007, 1, 1);

            ProjectStatus oldProjectStatus =
                ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building, lastBuildDate);
            ProjectStatus newProjectStatus =
                ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Building, lastBuildDate);
            bool result = new PollIntervalReporter(oldProjectStatus, newProjectStatus).HasNewBuildStarted;

            Assert.IsFalse(result);

            oldProjectStatus = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping, lastBuildDate);
            newProjectStatus = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping, lastBuildDate);
            result           = new PollIntervalReporter(oldProjectStatus, newProjectStatus).HasNewBuildStarted;
            Assert.IsFalse(result);
        }
Ejemplo n.º 20
0
        public void ShouldCopyLastBuildDateToProjectRow()
        {
            // Setup
            DateTime date = DateTime.Today;

            ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[]
            {
                new ProjectStatusOnServer(ProjectStatusFixture.New(projectSpecifier.ProjectName, IntegrationStatus.Success, date), serverSpecifier)
            };
            SetupProjectLinkExpectation();

            // Execute
            ProjectGridRow[] rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true, "", urlBuilderMock, new Translations("en-US"));

            // Verify
            Assert.AreEqual(DateUtil.FormatDate(date), rows[0].LastBuildDate);
            VerifyAll();
        }
Ejemplo n.º 21
0
        public void ShouldCopyProjectNameToProjectRow()
        {
            // Setup
            ProjectStatus projectStatus1 = ProjectStatusFixture.New(projectSpecifier.ProjectName);

            ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[]
            {
                new ProjectStatusOnServer(projectStatus1, serverSpecifier)
            };

            // Execute
            SetupProjectLinkExpectation();
            ProjectGridRow[] rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true, "", urlBuilderMock, new Translations("en-US"));

            // Verify
            Assert.AreEqual(1, rows.Length);
            Assert.AreEqual(projectSpecifier.ProjectName, rows[0].Name);
            VerifyAll();
        }
Ejemplo n.º 22
0
        public void DisplayBalloonMessageWhenNewMessageIsReceived()
        {
            ProjectStatus initial = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);

            mockProjectManager.ExpectAndReturn("ProjectName", PROJECT_NAME);
            mockServerMonitor.ExpectAndReturn("GetProjectStatus", initial, PROJECT_NAME);

            Message       expectedMessage = new Message("foo");
            ProjectStatus newStatus       = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);

            newStatus.Messages = new Message[] { expectedMessage };
            mockProjectManager.ExpectAndReturn("ProjectName", PROJECT_NAME);
            mockServerMonitor.ExpectAndReturn("GetProjectStatus", newStatus, PROJECT_NAME);

            monitor.MessageReceived += new MessageEventHandler(OnMessageReceived);
            monitor.Poll();
            monitor.Poll();
            Assert.AreEqual(actualMessage, expectedMessage);
        }
Ejemplo n.º 23
0
        public void ShouldHandleResultsWithNoBuildLabel()
        {
            // Setup
            ProjectStatus projectStatus1 = ProjectStatusFixture.New(projectSpecifier.ProjectName, null);

            ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[]
            {
                new ProjectStatusOnServer(projectStatus1, serverSpecifier)
            };

            // Execute
            SetupProjectLinkExpectation();
            ProjectGridRow[] rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true, "", urlBuilderMock, new Translations("en-US"));

            // Verify
            Assert.AreEqual(1, rows.Length);
            Assert.AreEqual("no build available", rows[0].LastBuildLabel);
            VerifyAll();
        }
Ejemplo n.º 24
0
        public void AllStatusMessagesReturnsMustReturnThemAll()
        {
            Message latestMessage = new Message("latest message");
            Message firstMessage  = new Message("message");


            ProjectStatus oldProjectStatus = ProjectStatusFixture.New("test project");

            oldProjectStatus.Messages = new Message[] {};
            ProjectStatus newProjectStatus = ProjectStatusFixture.New("test project");

            newProjectStatus.Messages = new Message[] { firstMessage, latestMessage };
            PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(newProjectStatus, newProjectStatus);

            System.Text.StringBuilder expected = new System.Text.StringBuilder();
            expected.AppendLine(firstMessage.Text);
            expected.Append(latestMessage.Text);


            Assert.AreEqual(new Message(expected.ToString()), pollIntervalReporter.AllStatusMessages);
        }
        public void DisplayBalloonMessageWhenNewMessageIsReceived()
        {
            monitor.MessageReceived += new MessageEventHandler(OnMessageReceived);
            ProjectStatus initial = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);

            mockProjectManager.SetupGet(_manager => _manager.ProjectName).Returns(PROJECT_NAME).Verifiable();
            mockServerMonitor.Setup(_monitor => _monitor.GetProjectStatus(PROJECT_NAME)).Returns(initial).Verifiable();

            monitor.Poll();
            Assert.AreEqual(actualMessage, null);

            Message       expectedMessage = new Message("foo");
            ProjectStatus newStatus       = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);

            newStatus.Messages = new Message[] { expectedMessage };
            mockProjectManager.SetupGet(_manager => _manager.ProjectName).Returns(PROJECT_NAME).Verifiable();
            mockServerMonitor.Setup(_monitor => _monitor.GetProjectStatus(PROJECT_NAME)).Returns(newStatus).Verifiable();

            monitor.Poll();
            Assert.AreEqual(actualMessage, expectedMessage);
        }
Ejemplo n.º 26
0
 private static ProjectStatus CreateProjectStatus(string projectName)
 {
     return(ProjectStatusFixture.New(projectName));
 }
Ejemplo n.º 27
0
        public void ShouldCopyBuildStatusToProjectRow()
        {
            // Setup
            ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[]
            {
                new ProjectStatusOnServer(ProjectStatusFixture.New(projectSpecifier.ProjectName, IntegrationStatus.Success), serverSpecifier)
            };

            SetupProjectLinkExpectation();
            mocks.ReplayAll();

            // Execute
            ProjectGridRow[] rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true, "", urlBuilderMock, new Translations("en-US"));

            // Verify
            Assert.AreEqual("Success", rows[0].BuildStatus);
            Assert.AreEqual(Color.Green.Name, rows[0].BuildStatusHtmlColor);

            // Setup
            statusses = new ProjectStatusOnServer[]
            {
                new ProjectStatusOnServer(ProjectStatusFixture.New(projectSpecifier.ProjectName, IntegrationStatus.Failure), serverSpecifier)
            };
            SetupProjectLinkExpectation();

            // Execute
            rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true, "", urlBuilderMock, new Translations("en-US"));

            // Verify
            Assert.AreEqual("Failure", rows[0].BuildStatus);
            Assert.AreEqual(Color.Red.Name, rows[0].BuildStatusHtmlColor);

            // Setup
            statusses = new ProjectStatusOnServer[]
            {
                new ProjectStatusOnServer(ProjectStatusFixture.New(projectSpecifier.ProjectName, IntegrationStatus.Unknown), serverSpecifier)
            };
            SetupProjectLinkExpectation();

            // Execute
            rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true, "", urlBuilderMock, new Translations("en-US"));

            // Verify
            Assert.AreEqual("Unknown", rows[0].BuildStatus);
            Assert.AreEqual(Color.Blue.Name, rows[0].BuildStatusHtmlColor);

            // Setup
            statusses = new ProjectStatusOnServer[]
            {
                new ProjectStatusOnServer(ProjectStatusFixture.New(projectSpecifier.ProjectName, IntegrationStatus.Exception), serverSpecifier)
            };
            SetupProjectLinkExpectation();

            // Execute
            rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true, "", urlBuilderMock, new Translations("en-US"));

            // Verify
            Assert.AreEqual("Exception", rows[0].BuildStatus);
            Assert.AreEqual(Color.Red.Name, rows[0].BuildStatusHtmlColor);

            VerifyAll();
        }
 private ProjectStatus NewProjectStatus(string name, IntegrationStatus integrationStatus, DateTime dateTime)
 {
     return(ProjectStatusFixture.New(name, integrationStatus, dateTime));
 }
 private ProjectStatus CreateProjectStatus(IntegrationStatus integrationStatus, DateTime lastBuildDate)
 {
     return(ProjectStatusFixture.New(integrationStatus, lastBuildDate));
 }
 private ProjectStatus CreateProjectStatus(IntegrationStatus integrationStatus, ProjectActivity activity)
 {
     return(ProjectStatusFixture.New(integrationStatus, activity));
 }