public void FindQuickestPath_FindsTwoEqualPaths_SticksWithTheFirstFoundOne() { //ARRANGE Network dummy = DummyCreator.CreateDummyNetworkOfTenNodesWithConnectionsOption2(); PathFinder sut = new PathFinder(dummy); double expectedQuickestPath = 10d; List <string> expectedNodesVisited = new List <string> { "A", "B" }; //ACT sut.FindQuickestPath("A", "B"); double actualQuickestPath = sut.QuickestPathResults["B"].QuickestTimeFromStart; List <string> actualNodesVisited = sut.QuickestPathResults["B"].NodesVisited; //ASSERT Assert.AreEqual(expectedQuickestPath, actualQuickestPath); for (int i = 0; i < expectedNodesVisited.Count; i++) { Assert.AreEqual(expectedNodesVisited[i], actualNodesVisited[i]); } }
public void FindQuickestPath_HappyDaysScenarioFive_GivesRightResult() { //ARRANGE Network dummy = DummyCreator.CreateDummyNetworkOfTenNodesWithConnectionsOption2(); PathFinder sut = new PathFinder(dummy); double expectedQuickestPath = 25d; List <string> expectedNodesVisited = new List <string> { "A", "B", "J", "D", "I", "H" }; //ACT sut.FindQuickestPath("A", "H"); double actualQuickestPath = sut.QuickestPathResults["H"].QuickestTimeFromStart; List <string> actualNodesVisited = sut.QuickestPathResults["H"].NodesVisited; //ASSERT Assert.AreEqual(expectedQuickestPath, actualQuickestPath); for (int i = 0; i < expectedNodesVisited.Count; i++) { Assert.AreEqual(expectedNodesVisited[i], actualNodesVisited[i]); } }
public void FindQuickestPath_StoppingAtEndNode_RightPathsShouldBeExploredAndNotExplored() { //ARRANGE Network dummy = DummyCreator.CreateDummyNetworkOfTenNodesWithConnectionsOption2(); PathFinder sut = new PathFinder(dummy); //ACT sut.FindQuickestPath("J", "D"); //ASSERT //Should be explored Assert.AreEqual(15, sut.QuickestPathResults["A"].QuickestTimeFromStart); Assert.AreEqual(5, sut.QuickestPathResults["B"].QuickestTimeFromStart); Assert.AreEqual(13, sut.QuickestPathResults["C"].QuickestTimeFromStart); Assert.AreEqual(7, sut.QuickestPathResults["D"].QuickestTimeFromStart); Assert.AreEqual(9, sut.QuickestPathResults["I"].QuickestTimeFromStart); Assert.AreEqual(0, sut.QuickestPathResults["J"].QuickestTimeFromStart); //Should not be explored Assert.AreEqual(double.PositiveInfinity, sut.QuickestPathResults["E"].QuickestTimeFromStart); Assert.AreEqual(double.PositiveInfinity, sut.QuickestPathResults["F"].QuickestTimeFromStart); Assert.AreEqual(double.PositiveInfinity, sut.QuickestPathResults["G"].QuickestTimeFromStart); Assert.AreEqual(double.PositiveInfinity, sut.QuickestPathResults["H"].QuickestTimeFromStart); }