public void CtorShouldSetPropertiesCorrectly() { // arrange var tspNodes = new List<TspNode> { new TspNode(1, 4.5, 6.7), new TspNode(1, 4.5, 6.7), new TspNode(1, 4.5, 6.7) }; const int tourLength = 234; const string tourInfo = "test"; var ids = from n in tspNodes select n.Id.ToString(); var nodeSequence = ids.Aggregate((a, b) => a + "," + b); // act var listViewTourItem = new ListViewTourItem(tspNodes, tourLength, tourInfo); // assert Assert.AreEqual(tourLength, listViewTourItem.Length); Assert.AreEqual(tourInfo, listViewTourItem.TourInfo); Assert.AreEqual(nodeSequence, listViewTourItem.NodeSequence); Assert.AreEqual(tspNodes, listViewTourItem.Nodes); }
/// <summary> /// Draw the tour item and, optionally, the optimal tour. /// </summary> /// <param name="tourItem">The tour item to draw.</param> /// <param name="drawOptimal">Draw the optimal tour as well (if available).</param> /// <param name="canvasSizeChanged">True if the window has been resized.</param> public void DrawTspLibItem(ListViewTourItem tourItem, bool drawOptimal, bool canvasSizeChanged) { if (canvasSizeChanged) { InitialiseTransformer(); } _canvas.Children.Clear(); foreach (var node in _currentTspItemManager.TspNodes) { DrawNode(node.Id, new Point { X = node.X, Y = node.Y }, Brushes.Black, false); } DrawSelectedTour(tourItem); if (drawOptimal) { DrawOptimalTour(); } }
/// <summary> /// Draws the tour currently selected in the ListView. /// </summary> private void DrawSelectedTour(ListViewTourItem tourItem) { if (tourItem != null) { DrawTour(tourItem.Nodes, tourItem.Length, Brushes.OrangeRed, Brushes.DodgerBlue); } }