public void GetLocationsForSegmentInCorrectOrder() { var network = CreateThreeNodesNetwork(); var branch = (Branch)network.Branches[0]; var source = new NetworkCoverage { Network = network }; source[new NetworkLocation(branch, 10.0)] = 10.0; source[new NetworkLocation(branch, 50.0)] = 30.0; source[new NetworkLocation(branch, 60.0)] = 20.0; source[new NetworkLocation(branch, 80.0)] = 10.0; // retrieve the location of source that overlap with segmentUp var segmentUp = new NetworkSegment { Branch = branch, Chainage = 30, Length = 40 }; var locationsUp = RouteHelper.GetLocationsForSegment(segmentUp, source, false).ToList(); Assert.AreEqual(new NetworkLocation(branch, 50.0), locationsUp[0]); Assert.AreEqual(new NetworkLocation(branch, 60.0), locationsUp[1]); // retrieve the location of source that overlap with segmentDown; the direction // is negative and the location offset are thus descending var segmentDown = new NetworkSegment { Branch = branch, Chainage = 90, Length = 50, DirectionIsPositive = false }; var locationsDown = RouteHelper.GetLocationsForSegment(segmentDown, source, false).ToList(); Assert.AreEqual(new NetworkLocation(branch, 80.0), locationsDown[0]); Assert.AreEqual(new NetworkLocation(branch, 60.0), locationsDown[1]); Assert.AreEqual(new NetworkLocation(branch, 50.0), locationsDown[2]); }