private void DisplayPathResults(PathResults pathDetails) { this.labelTotalResistance.Text = pathDetails.TotalResistance.ToString(); this.labelDidPathMakeIt.Text = pathDetails.DidWaterFlowThroughEntireGrid ? "Yes" : "No"; StringBuilder sb = new StringBuilder(); pathDetails.PathTaken.Each(i => { sb.Append(i).Append(" "); }); this.labelPathTaken.Text = sb.ToString(); }
private void HighlightPath(int width, PathResults pathDetails) { Color cellColor = pathDetails.DidWaterFlowThroughEntireGrid ? Color.Green : Color.Red; for (int i = 0; i < pathDetails.PathTaken.Count; i++) { this.dataGridView1[i, pathDetails.PathTaken[i] - 1].Style.BackColor = cellColor; } }
public void ArePathResultsComparedForEqualityProperly() { PathResults firstResults = new PathResults() { DidWaterFlowThroughEntireGrid = true, PathTaken = new List<int>(new int[] { 2, 4, 5, 1, 10 }), TotalResistance = 15 }; PathResults secondResults = new PathResults() { DidWaterFlowThroughEntireGrid = true, PathTaken = new List<int>(new int[] { 2, 4, 5, 1, 10 }), TotalResistance = 15 }; Assert.AreEqual(firstResults, secondResults, "The Two Paths Are Not Equal"); }
private void PaintGridAndPathOnUi(Grid grid, PathResults pathDetails) { this.dataGridView1.DataSource = grid.ToDataSet().Tables[0]; this.DisplayPathResults(pathDetails); this.HighlightPath(grid.Width, pathDetails); }