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); }
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); }
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); }
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); }
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); }
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); }
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); }
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()); }
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); }
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); }
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); }
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); }
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"); }
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"); }
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); }
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(); }
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(); }
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); }
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(); }
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); }
private static ProjectStatus CreateProjectStatus(string projectName) { return(ProjectStatusFixture.New(projectName)); }
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)); }