Beispiel #1
0
        public void Launched_ExactlyFiveMinutesAgo_ShouldNot_RemainInList()
        {
            DateTime   exactlyFiveMinutesAgo = DateTime.Now.Subtract(new TimeSpan(0, 5, 0));
            LaunchInfo li = CreateLaunchInfoWithTime(exactlyFiveMinutesAgo);

            MockLaunchInfoProvider mock = new MockLaunchInfoProvider();

            mock.LaunchList.Add(li);

            SpaceportDepartureBoard sut = new SpaceportDepartureBoard(mock);

            sut.RemoveInactiveLaunches();

            Assert.AreEqual(0, sut.LaunchList.Count, "Launched 5 minutes ago, should be removed from list of launches");
        }
Beispiel #2
0
        public void Launched_LessThanOneSecondUnderWindowToRemove_Should_RemainInList()
        {
            DateTime   almostFiveMinutesAgo = DateTime.Now.Subtract(new TimeSpan(0, 0, 5, 0)).AddMilliseconds(10);
            LaunchInfo li = CreateLaunchInfoWithTime(almostFiveMinutesAgo);

            MockLaunchInfoProvider mock = new MockLaunchInfoProvider();

            mock.LaunchList.Add(li);

            SpaceportDepartureBoard sut = new SpaceportDepartureBoard(mock);

            sut.RemoveInactiveLaunches();

            Assert.AreEqual(1, sut.LaunchList.Count, "Launched less than 5 minutes ago, should still be on the board");
        }
Beispiel #3
0
        public void Launched_WellUnderWindowToRemove_Should_RemainInList()
        {
            DateTime   fourMinutesAgo = DateTime.Now.Subtract(new TimeSpan(0, 0, 4, 0));
            LaunchInfo li             = CreateLaunchInfoWithTime(fourMinutesAgo);

            MockLaunchInfoProvider mock = new MockLaunchInfoProvider();

            mock.LaunchList.Add(li);

            SpaceportDepartureBoard sut = new SpaceportDepartureBoard(mock);

            sut.RemoveInactiveLaunches();

            Assert.AreEqual(1, sut.LaunchList.Count, "Launched four minutes ago, should still be on the board");
        }
Beispiel #4
0
 public void OnLaunchInfoChanged(LaunchInfo info)
 {
     if (info.Status == LaunchInfo.LaunchStatus.Delayed)
     {
         HandleDelayedLaunch();
     }
     else if (info.Status == LaunchInfo.LaunchStatus.Scrubbed)
     {
         HandleScrubbedLaunch();
     }
     else
     {
         AddNewLaunch(info);
     }
 }
Beispiel #5
0
        internal void RemoveInactiveLaunches()
        {
            DateTime now = DateTime.Now;

            for (int i = LaunchList.Count - 1; i >= 0; i--)
            {
                LaunchInfo launchInfo = LaunchList[i];
                if (launchInfo.Status == LaunchInfo.LaunchStatus.Launched)
                {
                    if (launchInfo.Time.AddMinutes(5).CompareTo(now) <= 0)
                    {
                        LaunchList.RemoveAt(i);
                    }
                }
                else if (launchInfo.Status == LaunchInfo.LaunchStatus.Scrubbed)
                {
                    if (launchInfo.Time.AddMinutes(10).CompareTo(now) <= 0)
                    {
                        LaunchList.RemoveAt(i);
                    }
                }
            }
        }
Beispiel #6
0
 private void AddNewLaunch(LaunchInfo info)
 {
     LaunchList.Add(info);
 }