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);
		}
		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 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 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);
		}
Beispiel #5
0
        public void Poll()
        {
            try
            {
                ProjectStatus newProjectStatus = serverMonitor.GetProjectStatus(ProjectName);
                if (lastProjectStatus != null && newProjectStatus != null)
                {
                    PollIntervalReporter duringInterval = new PollIntervalReporter(lastProjectStatus, newProjectStatus);

                    if (duringInterval.IsAnotherBuildComplete && duringInterval.WasLatestBuildSuccessful)
                    {
                        buildDurationTracker.OnSuccessfulBuild();
                    }
                    if (duringInterval.IsAnotherBuildComplete)
                    {
                        OnBuildOccurred(new MonitorBuildOccurredEventArgs(this, duringInterval.BuildTransition));
                    }

                    if (duringInterval.HasNewBuildStarted)
                    {
                        buildDurationTracker.OnBuildStart();
                    }

                    if (duringInterval.WasNewStatusMessagesReceived)
                    {
                        OnMessageReceived(newProjectStatus.Name, duringInterval.AllStatusMessages);
                    }
                }
                lastProjectStatus = newProjectStatus;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception during poll: " + ex);
                lastProjectStatus = null;
                connectException  = ex;
            }

            OnPolled(new MonitorPolledEventArgs(this));
        }
		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 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 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 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 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);
		}