public void The_holiday_information_for_a_multiple_people_is_loaded_from_disk_and_sent_to_the_view_when_the_day_changes()
        {
            AddPersonsLeave(new DateTime(2016, 10, 28), "Paul");
            AddPersonsLeave(new DateTime(2016, 10, 28), "Steve");
            SaveLeaveToFakeDisk();

            var configuration = new InformationRadiatorItemConfiguration();
            var presenter     = new HolidayCalendarPresenter(configuration);


            List <HolidayCalendarDay> days = null;

            presenter.HolidayCalendarUpdate += (sender, e) =>
            {
                days = e.Days;
            };

            timer.Raise(t => t.Tick += null, timer.Object, EventArgs.Empty);

            Assert.IsNotNull(days);
            Assert.AreEqual(1, days.Count);
            Assert.AreEqual(new DateTime(2016, 10, 28), days[0].Date);

            Assert.AreEqual(2, days[0].PeopleOnLeave.Count);
            Assert.IsTrue(days[0].PeopleOnLeave.Contains("Paul"));
            Assert.IsTrue(days[0].PeopleOnLeave.Contains("Steve"));
        }
        public void The_holiday_information_for_a_single_person_is_loaded_from_disk_and_sent_to_the_view_when_the_day_changes()
        {
            leave.DownloadDateTime = new DateTime(2016, 10, 26);
            AddPersonsLeave(new DateTime(2016, 10, 28), "Byran");
            SaveLeaveToFakeDisk();

            var configuration = new InformationRadiatorItemConfiguration();
            var presenter     = new HolidayCalendarPresenter(configuration);


            List <HolidayCalendarDay> days = null;
            DateTime downloadedDate        = DateTime.MinValue;

            presenter.HolidayCalendarUpdate += (sender, e) =>
            {
                days           = e.Days;
                downloadedDate = e.DownloadedTime;
            };

            timer.Raise(t => t.Tick += null, timer.Object, EventArgs.Empty);

            Assert.IsNotNull(days);
            Assert.AreEqual(1, days.Count);
            Assert.AreEqual(new DateTime(2016, 10, 28), days[0].Date);

            Assert.AreEqual(1, days[0].PeopleOnLeave.Count);
            Assert.AreEqual("Byran", days[0].PeopleOnLeave[0]);

            Assert.AreEqual(new DateTime(2016, 10, 26), downloadedDate);
        }
Exemple #3
0
        public void When_no_data_for_archipelagos_have_been_received_and_the_label_timer_ticks_then_the_view_is_not_updated()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView += (sender, eventArgs) => { };

            List <string> textualLabelText = new List <string>();

            presenter.DisplayTextualDataUpdate += (sender, eventArgs) =>
            {
                textualLabelText.Add(eventArgs.TextToDisplay);
            };

            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // When
            _mockTextualUpdateTimer.Raise(m => m.Tick += null, EventArgs.Empty);   // force a tick

            // Then
            var actualNumberOfTimeLabelHasBeenUpdated   = textualLabelText.Count;
            var expectedNumberOfTimeLabelHasBeenUpdated = 0;

            Assert.AreEqual(expectedNumberOfTimeLabelHasBeenUpdated, actualNumberOfTimeLabelHasBeenUpdated);

            _mockIslands.VerifyAll();
            _mockPythonScriptRunner.VerifyAll();
        }
        public void Only_holiday_information_for_the_next_two_weeks_is_sent_to_the_view()
        {
            AddPersonsLeave(factory.Date().AddDays(-1), "Paul");
            AddPersonsLeave(factory.Date(), "Steve");
            AddPersonsLeave(factory.Date().AddDays(13), "Jenny");
            AddPersonsLeave(factory.Date().AddDays(14), "Byran");
            SaveLeaveToFakeDisk();

            var configuration = new InformationRadiatorItemConfiguration();
            var presenter     = new HolidayCalendarPresenter(configuration);


            List <HolidayCalendarDay> days = null;

            presenter.HolidayCalendarUpdate += (sender, e) =>
            {
                days = e.Days;
            };

            timer.Raise(t => t.Tick += null, timer.Object, EventArgs.Empty);

            Assert.IsNotNull(days);
            Assert.AreEqual(2, days.Count);

            Assert.AreEqual(factory.Date(), days[0].Date);
            Assert.AreEqual(1, days[0].PeopleOnLeave.Count);
            Assert.IsTrue(days[0].PeopleOnLeave.Contains("Steve"));

            Assert.AreEqual(factory.Date().AddDays(13), days[1].Date);
            Assert.AreEqual(1, days[1].PeopleOnLeave.Count);
            Assert.IsTrue(days[1].PeopleOnLeave.Contains("Jenny"));
        }
Exemple #5
0
        public void Finishing_the_initialisation_adds_the_release_archipelago_to_the_view()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());

            var dummyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(dummyConfiguration);

            var    wait = new System.Threading.AutoResetEvent(false);
            string nameOfIslandAddedToView = null;

            presenter.AddNewIslandToView += (sender, eventArgs) =>
            {
                nameOfIslandAddedToView = eventArgs.Name;
                wait.Set();
            };
            presenter.DisplayTextualDataUpdate += (sender, eventArgs) => { };

            // When
            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // Then
            Assert.IsTrue(wait.WaitOne(1000), "did not add island to view within 1 second");

            Assert.AreEqual("Release Archipelago", nameOfIslandAddedToView);

            _mockPythonScriptRunner.VerifyAll();
        }
        private void ParseConfiguration(InformationRadiatorItemConfiguration configuration)
        {
            foreach (var item in configuration)
            {
                switch (item.ID.ToLower())
                {
                case "startdate":
                    DateTime date;
                    if (DateTime.TryParse(item.Value, out date))
                    {
                        _startDate = date.Date;
                    }
                    break;

                case "dayofsprint":
                    bool inverted;
                    if (bool.TryParse(item.Value, out inverted))
                    {
                        _dayOfSprint = inverted;
                    }
                    break;

                case "daysinsprint":
                    int days;
                    if (int.TryParse(item.Value, out days))
                    {
                        _daysInSprint = days;
                    }
                    break;
                }
            }
        }
Exemple #7
0
        private void ParseConfiguration(InformationRadiatorItemConfiguration configuration)
        {
            SetDefaultConfiguration();

            foreach (var item in configuration)
            {
                switch (item.ID.ToLower())
                {
                case "url":
                    _uRLs.Add(item.Value);
                    break;

                case "username":
                    _userName = item.Value;
                    break;

                case "password":
                    _password = item.Value;
                    break;

                case "maxy":
                    decimal value;
                    if (decimal.TryParse(item.Value, out value))
                    {
                        AutoscaleGraphYAxis = false;
                        GraphYAxisMax       = value;
                    }
                    break;
                }
            }
        }
Exemple #8
0
        public void When_the_python_script_timer_ticks_it_runs_the_script()
        {
            // Given
            CreateMockFactory();

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView       += (sender, eventArgs) => { };
            presenter.DisplayTextualDataUpdate += (sender, eventArgs) => { };

            var pythonScriptStartedCount = 0;

            _mockPythonScriptRunner.Setup(m => m.Go()).Callback(() =>
            {
                pythonScriptStartedCount++;
            });

            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // When
            _mockPythonScriptUpdateTimer.Raise(m => m.Tick += null, EventArgs.Empty);   // force a tick

            // Then
            var expectedPythonScriptStartedCount = 1; // for presenter.FinishInitialisation(...)

            expectedPythonScriptStartedCount++;       // for _mockPythonScriptUpdateTimer ticking
            Assert.AreEqual(expectedPythonScriptStartedCount, pythonScriptStartedCount);

            _mockPythonScriptRunner.VerifyAll();
        }
Exemple #9
0
        public void An_empty_configuration_makes_the_timers_have_default_interval_times()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView       += (sender, eventArgs) => { };
            presenter.DisplayTextualDataUpdate += (sender, eventArgs) => { };

            // When
            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // Then
            var    actualTextualUpdateTimerInterval = _factory._timersToIntervals[_mockTextualUpdateTimer.Object];
            double defaultInterval = 6 * 1000;

            Assert.AreEqual(defaultInterval, actualTextualUpdateTimerInterval);

            var actualPythonScriptUpdateTimerInterval = _factory._timersToIntervals[_mockPythonScriptUpdateTimer.Object];

            defaultInterval = ((0.5 * 60) * 60) * 1000;
            Assert.AreEqual(defaultInterval, actualPythonScriptUpdateTimerInterval);

            _mockPythonScriptRunner.VerifyAll();
        }
        public void Specifying_the_server_configuration()
        {
            // Given
            string expectedHostName = "absw";
            string expectedUserName = "******";
            string expectedPassword = "******";

            var configuration = new InformationRadiatorItemConfiguration();

            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "HostName", Value = expectedHostName
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "UserName", Value = expectedUserName
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "Password", Value = expectedPassword
            });

            // When
            var target = new LeanKitPresenter(configuration);

            // Then
            Assert.AreEqual(expectedHostName, mockFactory._pointsHostName);
            Assert.AreEqual(expectedUserName, mockFactory._pointsUserName);
            Assert.AreEqual(expectedPassword, mockFactory._pointsPassword);
        }
Exemple #11
0
        public void When_the_textual_update_timer_ticks_it_does_nothing_when_there_are_no_islands()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView += (sender, eventArgs) => { };

            var displayTextualDataUpdateCallCount = 0;

            presenter.DisplayTextualDataUpdate += (sender, eventArgs) =>
            {
                displayTextualDataUpdateCallCount++;
            };

            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // When
            _mockTextualUpdateTimer.Raise(m => m.Tick += null, EventArgs.Empty);   // force a tick

            // Then
            var expectedDisplayTextualDataUpdateCallCount = 0;

            Assert.AreEqual(expectedDisplayTextualDataUpdateCallCount, displayTextualDataUpdateCallCount);
        }
        private void ParseConfiguration(InformationRadiatorItemConfiguration configuration)
        {
            SetDefaultConfiguration();

            foreach (var item in configuration)
            {
                switch (item.ID.ToLower())
                {
                case "hostname":
                    _hostName = item.Value;
                    break;

                case "username":
                    _userName = item.Value;
                    break;

                case "password":
                    _password = item.Value;
                    break;

                case "buildconfiguration":
                    _configurations.Add(item.Value);
                    break;

                case "onlydefaultbranch":
                    bool onlyDefaultBranch;
                    if (bool.TryParse(item.Value, out onlyDefaultBranch))
                    {
                        _onlyDefaultBranch = onlyDefaultBranch;
                    }
                    break;
                }
            }
        }
        private InformationRadiatorItemConfiguration CreateConfiguration(string uRL = "Host", string userName = "******", string password = "******", string uRL2 = null)
        {
            var configuration = new InformationRadiatorItemConfiguration();

            configuration.Add(new InformationRadiatorItemConfigurationField()
            {
                ID = "URL", Value = uRL
            });
            if (uRL2 != null)
            {
                configuration.Add(new InformationRadiatorItemConfigurationField()
                {
                    ID = "URL", Value = uRL2
                });
            }
            configuration.Add(new InformationRadiatorItemConfigurationField()
            {
                ID = "UserName", Value = userName
            });
            configuration.Add(new InformationRadiatorItemConfigurationField()
            {
                ID = "Password", Value = password
            });
            return(configuration);
        }
Exemple #14
0
        public CoreQualityMetricsPresenter(InformationRadiatorItemConfiguration configuration, PresenterCommon.IDayUpdateMonitor updateMonitor)
        {
            ParseConfiguration(configuration);
            _webConnection = CoreQualityMetricsFactory.Instance.CreateWebsiteConnection(_websiteURL);

            updateMonitor.DayChanged += updateMonitor_DayChanged;
        }
Exemple #15
0
        private InformationRadiatorItemConfiguration AddDefaultConfiguration(int displayUpdatedInterval = 10, int fetchUpdateInterval = 360)
        {
            string expectedHostName = "absw";
            string expectedUserName = "******";
            string expectedPassword = "******";
            long   expectedBoardId  = 152;
            long   expectedLaneId   = 12;

            var configuration = new InformationRadiatorItemConfiguration();

            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "HostName", Value = expectedHostName
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "UserName", Value = expectedUserName
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "Password", Value = expectedPassword
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "BoardId", Value = expectedBoardId.ToString()
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "LaneId", Value = expectedLaneId.ToString()
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "DisplayUpdateInterval", Value = displayUpdatedInterval.ToString()
            });
            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "FetchUpdateInterval", Value = fetchUpdateInterval.ToString()
            });
            return(configuration);
        }
Exemple #16
0
        public void When_data_for_multiple_archipelagos_that_have_never_been_displayed_before_are_received_then_they_are_individually_added_to_the_view()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());
            _mockIslands.Setup(m => m.Contains(It.IsAny <string>())).Returns(false);
            _mockIslands.Setup(m => m.SetBranchDistance(It.IsAny <string>(), It.IsAny <double>()));
            _mockIslands.Setup(m => m.MoveAll());
            _mockIslands.Setup(m => m.Add(It.IsAny <GitVisualiser.Model.Branch>()));
            _mockIslands.Setup(m => m.GetLocation(It.IsAny <string>())).Returns(new System.Windows.Point(0, 0));
            _mockIslands.Setup(m => m.GetDistance(It.IsAny <string>())).Returns(0.0);
            _mockIslands.Setup(m => m.Highlight(It.IsAny <string>()));

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.DisplayTextualDataUpdate += (sender, eventArgs) => { };

            var actualIslandAddedToViewCount = 0;

            presenter.AddNewIslandToView += (sender, eventArgs) =>
            {
                actualIslandAddedToViewCount++;
            };

            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // When
            // add island via faking new data from python script
            _mockPythonScriptRunner.Raise(m =>
                                          m.FinishedEventHandler += null,
                                          new GitVisualiser.Model.PythonDataEventArgs(new List <Tuple <string, double> >
            {
                new Tuple <string, double>("a-new-archipelago", 100),
            }
                                                                                      ));

            _mockPythonScriptRunner.Raise(m =>
                                          m.FinishedEventHandler += null,
                                          new GitVisualiser.Model.PythonDataEventArgs(new List <Tuple <string, double> >
            {
                new Tuple <string, double>("bob", 100),
                new Tuple <string, double>("ben", 100),
                new Tuple <string, double>("bill", 100),
            }
                                                                                      ));

            // Then
            var expectedIslandAddedToViewCount = 5; // 1 for the release archipelago

            Assert.AreEqual(expectedIslandAddedToViewCount, actualIslandAddedToViewCount);

            _mockIslands.VerifyAll();
            _mockPythonScriptRunner.VerifyAll();
        }
Exemple #17
0
        public void When_a_new_archipelago_is_added_all_of_the_islands_move()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());
            _mockIslands.Setup(m => m.Contains(It.IsAny <string>())).Returns(false);
            _mockIslands.Setup(m => m.SetBranchDistance(It.IsAny <string>(), It.IsAny <double>()));
            var actualIslandsMoveAllCallCount = 0;

            _mockIslands.Setup(m => m.MoveAll()).Callback(() =>
            {
                actualIslandsMoveAllCallCount++;
            });
            _mockIslands.Setup(m => m.Add(It.IsAny <GitVisualiser.Model.Branch>()));
            _mockIslands.Setup(m => m.GetLocation(It.IsAny <string>())).Returns(new System.Windows.Point(0, 0));
            _mockIslands.Setup(m => m.GetDistance(It.IsAny <string>())).Returns(0.0);
            _mockIslands.Setup(m => m.Highlight(It.IsAny <string>()));

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView       += (sender, eventArgs) => { };
            presenter.DisplayTextualDataUpdate += (sender, eventArgs) => { };

            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // add island via faking new data from python script
            _mockPythonScriptRunner.Raise(m =>
                                          m.FinishedEventHandler += null,
                                          new GitVisualiser.Model.PythonDataEventArgs(new List <Tuple <string, double> >
            {
                new Tuple <string, double>("old-archipelago-data", 100),
                new Tuple <string, double>("more-old-archipelago-data", 100),
                new Tuple <string, double>("yet-more-old-archipelago-data", 100)
            }
                                                                                      )); // first move

            // When
            _mockPythonScriptRunner.Raise(m =>
                                          m.FinishedEventHandler += null,
                                          new GitVisualiser.Model.PythonDataEventArgs(new List <Tuple <string, double> >
            {
                new Tuple <string, double>("never-before-added-archipelago", 100),
                new Tuple <string, double>("another-never-before-added-archipelago", 100)
            }
                                                                                      )); // second move

            // Then
            var expectedIslandsMoveAllCallCount = 2;

            Assert.AreEqual(expectedIslandsMoveAllCallCount, actualIslandsMoveAllCallCount);

            _mockIslands.VerifyAll();
            _mockPythonScriptRunner.VerifyAll();
        }
        public GitVisualiserPresenter(InformationRadiatorItemConfiguration configuration)
        {
            _branchNames = new List <string>();
            _nextBranchDisplayedIndex = 0;

            ParseConfiguration(configuration);

            _mainThreadDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
        }
        public void The_update_timer_is_requested_at_a_5_minute_interval()
        {
            var configuration = new InformationRadiatorItemConfiguration();
            var presenter     = new HolidayCalendarPresenter(configuration);


            // The interval is in milliseconds
            Assert.AreEqual(300000, factory.timerInterval);
        }
 private void Initialise(IDayUpdateMonitor updateMonitor, InformationRadiatorItemConfiguration configuration)
 {
     _startDate    = new DateTime(2014, 8, 19);
     _dayOfSprint  = false;
     _daysInSprint = 10;
     ParseConfiguration(configuration);
     updateMonitor.DayChanged += updateMonitor_DayChanged;
     _sprintDaysLock           = new object();
 }
Exemple #21
0
        public void If_there_are_three_islands_and_we_have_ticked_thrice_then_when_we_tick_again_it_tells_the_view_to_update_the_label_to_be_for_the_first_island()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());
            _mockIslands.Setup(m => m.Contains(It.IsAny <string>())).Returns(false);
            _mockIslands.Setup(m => m.SetBranchDistance(It.IsAny <string>(), It.IsAny <double>()));
            _mockIslands.Setup(m => m.MoveAll());
            _mockIslands.Setup(m => m.Add(It.IsAny <GitVisualiser.Model.Branch>()));
            _mockIslands.Setup(m => m.GetLocation(It.IsAny <string>())).Returns(new System.Windows.Point(0, 0));
            _mockIslands.Setup(m => m.GetDistance(It.IsAny <string>())).Returns(100.0);
            _mockIslands.Setup(m => m.Highlight(It.IsAny <string>()));

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView += (sender, eventArgs) => { };

            List <string> textDisplayed = new List <string>();

            presenter.DisplayTextualDataUpdate += (sender, eventArgs) =>
            {
                textDisplayed.Add(eventArgs.TextToDisplay);
            };

            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // add islands via faking new data from python script
            _mockPythonScriptRunner.Raise(m =>
                                          m.FinishedEventHandler += null,
                                          new GitVisualiser.Model.PythonDataEventArgs(new List <Tuple <string, double> >
            {
                new Tuple <string, double>("one", 100),
                new Tuple <string, double>("two", 100),
                new Tuple <string, double>("three", 100)
            }
                                                                                      )); // forces 1 tick

            _mockTextualUpdateTimer.Raise(m => m.Tick += null, EventArgs.Empty);          // force a tick
            _mockTextualUpdateTimer.Raise(m => m.Tick += null, EventArgs.Empty);          // force a tick

            // When
            _mockTextualUpdateTimer.Raise(m => m.Tick += null, EventArgs.Empty);   // force a tick

            // Then
            var expectedIslandNameLastDisplayed = "one\r\n100";
            var actualIslandNameLastDisplayed   = textDisplayed[textDisplayed.Count - 1];

            Assert.AreEqual(expectedIslandNameLastDisplayed, actualIslandNameLastDisplayed);

            _mockIslands.VerifyAll();
            _mockPythonScriptRunner.VerifyAll();
        }
Exemple #22
0
        public TeamCityMetricsPresenter(InformationRadiatorItemConfiguration configuration)
        {
            _uRLs = new List <string>();
            ParseConfiguration(configuration);

            _metricsDownload = TeamCityFactory.Instance.CreateMetricsDownload(_userName, _password);
            _timer           = TeamCityFactory.Instance.CreateTimer(600000);

            _timer.Tick += _timer_Tick;
        }
Exemple #23
0
        public void When_the_textual_label_is_long_it_does_not_go_outsize_of_the_control()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());
            _mockIslands.Setup(m => m.Contains(It.IsAny <string>())).Returns(false);
            _mockIslands.Setup(m => m.SetBranchDistance(It.IsAny <string>(), It.IsAny <double>()));
            _mockIslands.Setup(m => m.MoveAll());
            _mockIslands.Setup(m => m.Add(It.IsAny <GitVisualiser.Model.Branch>()));
            _mockIslands.Setup(m => m.GetDistance(It.IsAny <string>())).Returns(0.0);
            _mockIslands.Setup(m => m.Highlight(It.IsAny <string>()));

            var controlWidth          = 200.0;
            var controlHeight         = 200.0;
            var edgeOfControlLocation = new System.Windows.Point(controlWidth - 10, controlHeight / 2);

            _mockIslands.Setup(m => m.GetLocation(It.IsAny <string>())).Returns(edgeOfControlLocation);

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView += (sender, eventArgs) => { };

            System.Windows.Point actualTextualLabelLocation = new System.Windows.Point();
            presenter.DisplayTextualDataUpdate += (sender, eventArgs) =>
            {
                actualTextualLabelLocation = eventArgs.Location;
            };

            presenter.FinishInitialisation(controlWidth, controlHeight);

            var longBranchName = "branch-name-that-is-really-very-long-indeed";

            // add island via faking new data from python script
            _mockPythonScriptRunner.Raise(m =>
                                          m.FinishedEventHandler += null,
                                          new GitVisualiser.Model.PythonDataEventArgs(new List <Tuple <string, double> >
            {
                // with a control width of 200, we should go out of the control
                new Tuple <string, double>(longBranchName, 500)
            }
                                                                                      ));

            // When
            _mockTextualUpdateTimer.Raise(m => m.Tick += null, EventArgs.Empty);   // force a tick

            // Then
            var textWidth = TestHelper_GetLabelWidthAndHeight(longBranchName + "\r\n500");
            var rightHandSideOfTheLabelLocation = actualTextualLabelLocation.X + textWidth;

            Assert.IsTrue(rightHandSideOfTheLabelLocation < controlWidth);

            _mockIslands.VerifyAll();
            _mockPythonScriptRunner.VerifyAll();
        }
        public LeanKitCumlativeFlowPresenter(InformationRadiatorItemConfiguration configuration, PresenterCommon.IDayUpdateMonitor updateMonitor)
        {
            NumberOfDaysHistory  = 10;
            _configurationParser = new LeanKitConfigurationParser();
            _configurationParser.UnknownConfigurationParameter += _configurationParser_UnknownConfigurationParameter;
            _configurationParser.ParseConfiguration(configuration);

            _history = LeanKitFactory.Instance.CreateLanePointsHistory(_configurationParser.HostName, _configurationParser.UserName, _configurationParser.Password, _configurationParser.BoardId, _configurationParser.IgnoredLanes);

            updateMonitor.DayChanged += updateMonitor_DayChanged;
        }
        public DecorationsPresenter(IDayUpdateMonitor updateMonitor, InformationRadiatorItemConfiguration configuration)
        {
            _forceChristmas = false;
            _forceEaster    = false;
            ParseConfiguration(configuration);
            updateMonitor.DayChanged += updateMonitor_DayChanged;

            _steveQuoteCounter      = 0;
            _steveQuoteTicks        = 0;
            _steveQuotesTimer       = PresenterCommonFactory.Instance.CreateTimer(20000);
            _steveQuotesTimer.Tick += _steveQuotesTimer_Tick;
        }
Exemple #26
0
        private CoreQualityMetricsPresenter CreateConfiguredTarget()
        {
            var configuration = new InformationRadiatorItemConfiguration();

            configuration.Add(new InformationRadiatorItemConfigurationField {
                ID = "WebsiteURL", Value = "http://192.168.1.1"
            });

            mockFactory.Setup(m => m.CreateWebsiteConnection("http://192.168.1.1")).Returns(mockWebsite.Object);

            return(new CoreQualityMetricsPresenter(configuration, mockDayUpdateMonitor.Object));
        }
Exemple #27
0
        public void The_default_configuration_is_valid()
        {
            // Given
            var configuration = new InformationRadiatorItemConfiguration();

            mockFactory.Setup(m => m.CreateWebsiteConnection("http://localhost/")).Returns(mockWebsite.Object);

            // When
            var target = new CoreQualityMetricsPresenter(configuration, mockDayUpdateMonitor.Object);

            // Then - mocks verified in the Cleanup()
        }
        public LeanKitPresenter(InformationRadiatorItemConfiguration configuration)
        {
            _configurationParser = new LeanKitConfigurationParser();
            _configurationParser.ParseConfiguration(configuration);

            _apiLock = new object();

            _points = LeanKitFactory.Instance.CreateLeanKitPoints(_configurationParser.HostName, _configurationParser.UserName, _configurationParser.Password);

            _timer       = LeanKitFactory.Instance.CreateTimer(updateInterval);
            _timer.Tick += _timer_Tick;
        }
        private void ParseConfiguration(InformationRadiatorItemConfiguration configuration)
        {
            foreach (var item in configuration)
            {
                switch (item.ID.ToLower())
                {
                case "scriptdirectory":
                    _distanceScriptDirectory = item.Value;
                    break;

                case "pythonexelocation":
                    _pythonExeLocation = item.Value;
                    break;

                case "minpixelsizeislandadditivemodifier":
                    _configFileMinPixelSizeIslandAdditiveModifier = ParseDouble(item.Value);
                    break;

                case "maxpixelsizeislandadditivemodifier":
                    _configFileMaxPixelSizeIslandAdditiveModifier = ParseDouble(item.Value);
                    break;

                case "pixelsperarchipelagounitdistanceadditivemodifier":
                    _pixelsPerArchipelagoUnitDistanceAdditiveModifier = ParseDouble(item.Value);
                    break;

                case "textualinformationdisplayticktimeinseconds":
                    _textualInformationDisplayTickTimeInMilliseconds = ParseDouble(item.Value) * 1000;
                    break;

                case "pythonscriptupdateticktimeinhours":
                    _pythonScriptUpdateTickTimeInMilliseconds = ((ParseDouble(item.Value) * 60) * 60) * 1000;
                    break;
                }
            }

            var didNotExistInConfigurationOrFailedParsing = (_textualInformationDisplayTickTimeInMilliseconds == 0);

            if (didNotExistInConfigurationOrFailedParsing)
            {
                var DefaultTimeoutInMilliseconds = 6 * 1000;
                _textualInformationDisplayTickTimeInMilliseconds = DefaultTimeoutInMilliseconds;
            }

            didNotExistInConfigurationOrFailedParsing = (_pythonScriptUpdateTickTimeInMilliseconds == 0);
            if (didNotExistInConfigurationOrFailedParsing)
            {
                var hours = 0.5;
                var DefaultTimeoutInMilliseconds = ((hours * 60) * 60) * 1000;
                _pythonScriptUpdateTickTimeInMilliseconds = DefaultTimeoutInMilliseconds;
            }
        }
Exemple #30
0
        public void When_data_for_multiple_archipelagos_that_have_never_been_displayed_before_is_received_then_the_view_is_told_to_update_the_label_once()
        {
            // Given
            CreateMockFactory();
            _mockPythonScriptRunner.Setup(m => m.Go());
            _mockIslands.Setup(m => m.Contains(It.IsAny <string>())).Returns(false);
            _mockIslands.Setup(m => m.SetBranchDistance(It.IsAny <string>(), It.IsAny <double>()));
            _mockIslands.Setup(m => m.MoveAll());
            _mockIslands.Setup(m => m.Add(It.IsAny <GitVisualiser.Model.Branch>()));
            _mockIslands.Setup(m => m.GetLocation(It.IsAny <string>())).Returns(new System.Windows.Point(0, 0));
            _mockIslands.Setup(m => m.GetDistance(It.IsAny <string>())).Returns(0.0);
            _mockIslands.Setup(m => m.Highlight(It.IsAny <string>()));

            var emptyConfiguration = new InformationRadiatorItemConfiguration();
            var presenter          = new GitVisualiserPresenter(emptyConfiguration);

            presenter.AddNewIslandToView += (sender, eventArgs) => { };

            List <string> textualLabelText = new List <string>();

            presenter.DisplayTextualDataUpdate += (sender, eventArgs) =>
            {
                textualLabelText.Add(eventArgs.TextToDisplay);
            };

            var controlWidth  = 100.0;
            var controlHeight = 200.0;

            presenter.FinishInitialisation(controlWidth, controlHeight);

            // When
            // add island via faking new data from python script
            _mockPythonScriptRunner.Raise(m =>
                                          m.FinishedEventHandler += null,
                                          new GitVisualiser.Model.PythonDataEventArgs(new List <Tuple <string, double> >
            {
                new Tuple <string, double>("hey", 100),
                new Tuple <string, double>("there", 100),
                new Tuple <string, double>("I", 100),
                new Tuple <string, double>("just", 100),
            }
                                                                                      ));

            // Then
            var actualNumberOfTimeLabelHasBeenUpdated   = textualLabelText.Count;
            var expectedNumberOfTimeLabelHasBeenUpdated = 1;

            Assert.AreEqual(expectedNumberOfTimeLabelHasBeenUpdated, actualNumberOfTimeLabelHasBeenUpdated);

            _mockIslands.VerifyAll();
            _mockPythonScriptRunner.VerifyAll();
        }