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.º 2
0
		public void SetUp()
		{
			stubProjectMonitor = new StubProjectMonitor("project");

			mockLampController = new DynamicMock(typeof(ILampController));
			mockLampController.Strict = true;
			ILampController lampController = mockLampController.MockInstance as ILampController;
			
			configuration = new X10Configuration();
			configuration.Enabled = true;
			configuration.StartTime = DateTime.Parse("08:00");
			configuration.EndTime = DateTime.Parse("18:00");
            configuration.ActiveDays[(int)DayOfWeek.Sunday] = false;
            configuration.ActiveDays[(int)DayOfWeek.Monday] = true;
            configuration.ActiveDays[(int)DayOfWeek.Tuesday] = true;
            configuration.ActiveDays[(int)DayOfWeek.Wednesday] = true;
            configuration.ActiveDays[(int)DayOfWeek.Thursday] = true;
            configuration.ActiveDays[(int)DayOfWeek.Friday] = true;
            configuration.ActiveDays[(int)DayOfWeek.Saturday] = false;
			
			stubCurrentTimeProvider = new StubCurrentTimeProvider();
			stubCurrentTimeProvider.SetNow(new DateTime(2005, 11, 03, 12, 00, 00));
			Assert.AreEqual(DayOfWeek.Thursday, stubCurrentTimeProvider.Now.DayOfWeek);

			new X10Controller(
				stubProjectMonitor, 
				stubCurrentTimeProvider, 
				configuration,
				lampController);
		}
        public void AfterASuccessfulBuildTheLastBuildTimeIsCalculated()
        {
            DateTime startTime = new DateTime(2005, 7, 20, 10, 15, 02);

            currentTimeProvider.SetNow(startTime);
            tracker.OnBuildStart();
            currentTimeProvider.SetNow(startTime.AddHours(2));
            tracker.OnSuccessfulBuild();

            Assert.AreEqual(TimeSpan.FromHours(2), tracker.LastBuildDuration);

            currentTimeProvider.SetNow(startTime);
            tracker.OnBuildStart();
            currentTimeProvider.SetNow(startTime.AddMinutes(4));

            Assert.AreEqual(TimeSpan.FromHours(2), tracker.LastBuildDuration);
            tracker.OnSuccessfulBuild();

            Assert.AreEqual(TimeSpan.FromMinutes(4), tracker.LastBuildDuration);
        }