public void AddToWptListCase1() { var wptList = Case1WptList(); var adder = new SidAdder( "AXYZ", new SidCollection(new List <SidEntry>()), wptList, wptList.GetEditor(), GetAirportManager()); int rwyIndex = adder.AddSidsToWptList("18", new List <string>()); // Check the SID is added as an edge Assert.AreEqual(2, wptList.EdgesFromCount(rwyIndex)); foreach (var j in wptList.EdgesFrom(rwyIndex)) { var edge = wptList.GetEdge(j); // Name is DCT Assert.AreEqual("DCT", edge.Value.Airway); // No inner waypoints. Assert.AreEqual(0, edge.Value.InnerWaypoints.Count); // Distance is correct Assert.AreEqual( wptList.Distance(rwyIndex, edge.ToNodeIndex), edge.Value.Distance, DistanceEpsilon); } }
private void AddToWptListCase3And5(WaypointList wptList) { var entry = new SidEntry( "18", "SID1", List(wpt101, wpt102, wpt103, wpt104), EntryType.RwySpecific, false); var adder = new SidAdder( "AXYZ", new SidCollection( List(entry)), wptList, wptList.GetEditor(), GetAirportManager()); int rwyIndex = adder.AddSidsToWptList("18", List("SID1")); // Check the SID has been added with correct total distance. var edges = wptList.EdgesFrom(rwyIndex).ToList(); Assert.IsTrue(edges.Count > 0); Assert.IsTrue(edges.Select(e => wptList.GetEdge(e)) .All(e => e.Value.InnerWaypoints.SequenceEqual(List(wpt101, wpt102, wpt103)) && e.Value.Type == InnerWaypointsType.Terminal)); double dis = List(rwy, wpt101, wpt102, wpt103, wpt104).TotalDistance(); Assert.IsTrue(SidIsAdded( rwyIndex, "SID1", dis, wptList)); // Check the edges of last wpt int index = wptList.FindByWaypoint(wpt104); Assert.AreEqual(2, wptList.EdgesFromCount(index)); foreach (var i in wptList.EdgesFrom(index)) { var edge = wptList.GetEdge(i); var neighbor = edge.Value; Assert.AreEqual("DCT", neighbor.Airway); Assert.AreEqual(0, neighbor.InnerWaypoints.Count); var expectedDis = wpt104.Distance(wptList[edge.ToNodeIndex]); Assert.AreEqual( expectedDis, neighbor.Distance, DistanceEpsilon); } }
public void AddToWptListCase2() { var wptList = Case2WptList(); var entry = new SidEntry( "18", "SID1", List(wpt101, wpt102), EntryType.RwySpecific, true); var adder = new SidAdder( "AXYZ", new SidCollection(List(entry)), wptList, wptList.GetEditor(), GetAirportManager()); int rwyIndex = adder.AddSidsToWptList("18", List("SID1")); var distance = List( rwy, wpt101, wpt102) .TotalDistance(); // Check the SID has been added with correct total distance. Assert.AreEqual(2, wptList.EdgesFromCount(rwyIndex)); // Check the edges of last wpt foreach (var i in wptList.EdgesFrom(rwyIndex)) { var edge = wptList.GetEdge(i); Assert.AreEqual("SID1", edge.Value.Airway); Assert.AreEqual(InnerWaypointsType.Terminal, edge.Value.Type); var expectedDis = distance + wpt102.Distance(wptList[edge.ToNodeIndex]); Assert.AreEqual( expectedDis, edge.Value.Distance, DistanceEpsilon); } }
public void AddToWptListCase4() { var wptList = Case4WptList(); var wpt01 = new Waypoint("WPT01", 25.0, 50.0); var wptCoord = new Waypoint("26N050E", 26.0, 50.0); var entry = new SidEntry( "18", "SID1", List(wpt01, wptCoord), EntryType.RwySpecific, false); var adder = new SidAdder( "AXYZ", new SidCollection(List(entry)), wptList, wptList.GetEditor(), GetAirportManager()); int rwyIndex = adder.AddSidsToWptList("18", List("SID1")); // Check the SID1 has been added with correct total distance. var edges = wptList.EdgesFrom(rwyIndex).ToList(); Assert.AreEqual(1, edges.Count); var edge = wptList.GetEdge(edges[0]); Assert.IsTrue(edge.Value.InnerWaypoints.SequenceEqual(new[] { wpt01 })); Assert.AreEqual(InnerWaypointsType.Terminal, edge.Value.Type); var dis = List(rwy, wpt01, wptCoord).TotalDistance(); Assert.IsTrue(SidIsAdded( rwyIndex, "SID1", dis, wptList)); }