public void Should_Explore_All_Single_Path_Routes_For_Given_Points() { // Arrange var startPoint = this.pointA; var endPoint = this.pointD; var routes = new List <Path> { new Path { Id = 4, PointOne = this.pointA, PointTwo = this.pointD, Distance = 20 }, new Path { Id = 5, PointOne = this.pointD, PointTwo = this.pointA, Distance = 14 }, new Path { Id = 6, PointOne = this.pointA, PointTwo = this.pointC, Distance = 5 } }; var sut = new RouteExplorer(); // Act var result = sut.GetAllPossibleRoutes(routes, startPoint, endPoint); // Assert var expectedOne = new Route { Paths = new List <Path> { new Path { Id = 4, PointOne = this.pointA, PointTwo = this.pointD, Distance = 20 }, } }; var expectedTwo = new Route { Paths = new List <Path> { new Path { Id = 5, PointOne = this.pointD, PointTwo = this.pointA, Distance = 14 }, } }; result.Count().Should().Be(2); result.Should().BeEquivalentTo( new List <Route> { expectedOne, expectedTwo } ); }
public void Should_Explore_All_Possible_Routes_For_Given_Points() { // Arrange var startPoint = this.pointA; var endPoint = this.pointD; var routes = new List <Path> { new Path { Id = 1, PointOne = this.pointA, PointTwo = this.pointB, Distance = 1 }, new Path { Id = 2, PointOne = this.pointB, PointTwo = this.pointC, Distance = 4 }, new Path { Id = 3, PointOne = this.pointC, PointTwo = this.pointD, Distance = 3 }, new Path { Id = 4, PointOne = this.pointA, PointTwo = this.pointD, Distance = 20 }, new Path { Id = 5, PointOne = this.pointA, PointTwo = this.pointC, Distance = 5 }, new Path { Id = 6, PointOne = this.pointC, PointTwo = this.pointE, Distance = 7 }, new Path { Id = 7, PointOne = this.pointH, PointTwo = this.pointB, Distance = 7 }, }; var sut = new RouteExplorer(); // Act var result = sut.GetAllPossibleRoutes(routes, startPoint, endPoint); // Assert var expectedOne = new Route { Paths = new List <Path> { new Path { Id = 1, PointOne = this.pointA, PointTwo = this.pointB, Distance = 1 }, new Path { Id = 2, PointOne = this.pointB, PointTwo = this.pointC, Distance = 4 }, new Path { Id = 3, PointOne = this.pointC, PointTwo = this.pointD, Distance = 3 }, } }; var expectedTwo = new Route { Paths = new List <Path> { new Path { Id = 1, PointOne = this.pointA, PointTwo = this.pointB, Distance = 1 }, new Path { Id = 2, PointOne = this.pointB, PointTwo = this.pointC, Distance = 4 }, new Path { Id = 5, PointOne = this.pointA, PointTwo = this.pointC, Distance = 5 }, new Path { Id = 4, PointOne = this.pointA, PointTwo = this.pointD, Distance = 20 }, } }; var expectedThree = new Route { Paths = new List <Path> { new Path { Id = 4, PointOne = this.pointA, PointTwo = this.pointD, Distance = 20 }, } }; var expectedFour = new Route { Paths = new List <Path> { new Path { Id = 5, PointOne = this.pointA, PointTwo = this.pointC, Distance = 5 }, new Path { Id = 3, PointOne = this.pointC, PointTwo = this.pointD, Distance = 3 }, } }; var expectedFive = new Route { Paths = new List <Path> { new Path { Id = 5, PointOne = this.pointA, PointTwo = this.pointC, Distance = 5 }, new Path { Id = 2, PointOne = this.pointB, PointTwo = this.pointC, Distance = 4 }, new Path { Id = 1, PointOne = this.pointA, PointTwo = this.pointB, Distance = 1 }, new Path { Id = 4, PointOne = this.pointA, PointTwo = this.pointD, Distance = 20 }, } }; result.Count().Should().Be(5); result.Should().BeEquivalentTo( new List <Route> { expectedOne, expectedTwo, expectedThree, expectedFive, expectedFour, } ); }