public Visualiser(Canvas canvas, TspLibItemManager currentTspItemManager)
        {
            _canvas = canvas;
              _currentTspItemManager = currentTspItemManager;

              InitialiseTransformer();
        }
        public void LoadItemGivenInvalidProblemNameShouldThrowArgumentException(string problemName)
        {
            // arrange
              var manager = new TspLibItemManager(Helpers.LibPath);

              // assert
              Assert.Throws<ArgumentException>(() => manager.LoadItem(problemName));
        }
        public void AllProblemNamesShouldMatchThatOfItemLoader()
        {
            // arrange
              var loader = new SymmetricTspItemLoader(Helpers.LibPath);
              var manager = new TspLibItemManager(Helpers.LibPath);

              // assert
              Assert.AreEqual(loader.ProblemNames, manager.AllProblemNames);
        }
        public void HasOptimalTourShouldMatchThatOfInfoProvider()
        {
            // arrange
              const string problemName = "eil76";
              var loader = new SymmetricTspItemLoader(Helpers.LibPath);
              var item = loader.GetItem(problemName);
              var infoProvider = new SymmetricTspItemInfoProvider(item);
              var manager = new TspLibItemManager(Helpers.LibPath);

              // act
              manager.LoadItem(problemName);

              // assert
              Assert.AreEqual(infoProvider.HasOptimalTour, manager.HasOptimalTour);
        }
        public void DistancesShouldMatchThatOfInfoProvider()
        {
            // arrange
              const string problemName = "eil76";
              var loader = new SymmetricTspItemLoader(Helpers.LibPath);
              var item = loader.GetItem(problemName);
              var infoProvider = new SymmetricTspItemInfoProvider(item);
              var manager = new TspLibItemManager(Helpers.LibPath);

              // act
              manager.LoadItem(problemName);

              // assert
              CollectionAssert.AreEqual(infoProvider.Distances, manager.Distances);
        }
        /// <summary>
        /// Called as soon as the main window is loaded.
        /// </summary>
        private void Initialise()
        {
            var tspLibPath = BrowseTsplibPath();

              // Load all symmetric TSP instances.
              _tspLibItemManager = new TspLibItemManager(tspLibPath);
              TspCombo.ItemsSource = _tspLibItemManager.AllProblemNames;
              SelectionStrategy.ItemsSource = Enum.GetNames(typeof(NodeSelectionStrategy));
              SelectionStrategy.SelectedIndex = (int)NodeSelectionStrategy.RouletteWheel;
        }
        public void MinMaxCoordinatesShouldMatchThatOfInfoProvider()
        {
            // arrange
              const string problemName = "eil76";
              var loader = new SymmetricTspItemLoader(Helpers.LibPath);
              var item = loader.GetItem(problemName);
              var infoProvider = new SymmetricTspItemInfoProvider(item);
              var manager = new TspLibItemManager(Helpers.LibPath);

              // act
              manager.LoadItem(problemName);

              // assert
              Assert.AreEqual(infoProvider.MaxXCoordinate, manager.MaxXCoordinate);
              Assert.AreEqual(infoProvider.MaxYCoordinate, manager.MaxYCoordinate);
              Assert.AreEqual(infoProvider.MinXCoordinate, manager.MinXCoordinate);
              Assert.AreEqual(infoProvider.MinYCoordinate, manager.MinYCoordinate);
        }