public void MergeBranchesWithCustomLength(bool isCustomLength) { //arrange : network with 2 branches var network = RouteHelperTest.GetSnakeNetwork(false, 2); if (isCustomLength) { network.Branches.ForEach(b => b.IsLengthCustom = true); } NetworkHelper.AddBranchFeatureToBranch(new TestBranchFeature(), network.Branches[0], 10.0); NetworkHelper.AddBranchFeatureToBranch(new TestBranchFeature(), network.Branches[0], 60.0); NetworkHelper.AddBranchFeatureToBranch(new TestBranchFeature(), network.Branches[1], 30.0); NetworkHelper.AddBranchFeatureToBranch(new TestBranchFeature(), network.Branches[1], 90.0); //action! the 2nd node is the connection node...remove it NetworkHelper.MergeNodeBranches(network.Nodes[1], network); Assert.AreEqual(4, network.BranchFeatures.Count()); var expectedChainage = new[] { 10.0, 60.0, 130.0, 190.0 }; var index = 0; foreach (var branchFeature in network.BranchFeatures) { Assert.AreEqual(network.Branches[0], branchFeature.Branch); Assert.AreEqual(expectedChainage[index++], branchFeature.Chainage); } }
public void CanNotMergeABranchWithCustomAndNonCustomLength() { //arrange : network with 2 branches : one custom and the other is not var network = RouteHelperTest.GetSnakeNetwork(false, 2); var branch1 = network.Branches[0]; var branch2 = network.Branches[1]; branch1.Name = "jan"; branch1.IsLengthCustom = true; branch1.Length = 40.0; branch2.Name = "klaas"; //action! this should throw an exception NetworkHelper.MergeNodeBranches(network.Nodes[1], network); }
public void MergeBranchesWithCustomLengthSumsTheCustomLength() { //arrange : network with 2 branches var network = RouteHelperTest.GetSnakeNetwork(false, 2); var branch1 = network.Branches[0]; var branch2 = network.Branches[1]; branch1.IsLengthCustom = true; branch1.Length = 40.0; branch2.IsLengthCustom = true; branch2.Length = 33.0; //action! the 2nd node is the connection node...remove it NetworkHelper.MergeNodeBranches(network.Nodes[1], network); Assert.AreEqual(73.0, branch1.Length); }