public void WhenMainRouteWptDoesNotExistShouldRecordFailure() { // Arrange var p1 = new Waypoint("P1", 0.0, 0.0); var p2 = new Waypoint("P2", 0.0, 2.0); var wptList = new WaypointList(); var route = new Route(); route.AddLastWaypoint(p1); route.AddLastWaypoint(p2, "DCT"); var nodes = new TrackNodes("A", "NATA", route, new List <WptPair>()); var recorder = new StatusRecorder(); var adder = new TrackAdder( wptList, wptList.GetEditor(), recorder, TrackType.Nats); // Act adder.AddToWaypointList(new[] { nodes }); // Assert Assert.AreEqual(1, recorder.Records.Count); }
private void ValidateFirstWpt(int index) { if (index == -1) { if (TryParseCoord(routeInput[0])) { return; } throw new ArgumentException($"{routeInput[0]} is not a valid coordinate."); } if (!wptList.WaypointExists(index)) { throw new ArgumentException("Wrong first waypoint index."); } var wpt = wptList[index]; if (routeInput[0] != wpt.ID) { throw new ArgumentException( "The first waypoint of the route does not match the " + "specified index in WptList."); } lastWpt = index; rte.AddLastWaypoint(wpt); }
private Route DirectRoute() { var route = new Route(); route.AddLastWaypoint(origRwyWpt); route.AddLastWaypoint(destRwyWpt, "DCT"); return(route); }
private Route GetRoute1() { var route = new Route(); route.AddLastWaypoint(new Waypoint("Y", 0.0, 1.0)); route.AddLastWaypoint(new Waypoint("Z", 0.0, 3.0), "1"); return(route); }
private Route GetRoute2() { var route = new Route(); route.AddLastWaypoint(new Waypoint("2", 0.0, 0.0)); route.AddLastWaypoint(new Waypoint("4", 0.0, 0.0), "C"); route.AddLastWaypoint(new Waypoint("3", 0.0, 0.0), "D"); return(route); }
private Route GetRoute1() { var route = new Route(); route.AddLastWaypoint(new Waypoint("1", 0.0, 0.0)); route.AddLastWaypoint(new Waypoint("2", 0.0, 0.0), "A"); route.AddLastWaypoint(new Waypoint("3", 0.0, 0.0), "B"); return(route); }
public void GetTotalDistanceCustomDistance() { var x = new Waypoint("X", 0.0, 0.0); var y = new Waypoint("Y", 0.0, 1.0); var z = new Waypoint("Z", 1.0, 3.0); var route = new Route(); route.AddLastWaypoint(x); route.AddLastWaypoint(y, "0", 100.0); route.AddLastWaypoint(z, "1", 200.0); Assert.AreEqual(300.0, route.TotalDistance(), 1E-8); }
/// <exception cref="ArgumentException"></exception> public static Route ToRoute(this IEnumerable <ICoordinate> coordinates) { var items = coordinates.ToList(); if (items.Count < 2) { throw new ArgumentException(); } var result = new Route(); foreach (var i in items) { double lat = i.Lat; double lon = i.Lon; string latLonTxt = Format5Letter.ToString(lat, lon) ?? FormatDecimal.ToString(lat, lon); var wpt = new Waypoint(latLonTxt, lat, lon); result.AddLastWaypoint(wpt, "DCT"); } return(result); }
public void GetTotalDistanceTest() { var x = new Waypoint("X", 0.0, 0.0); var y = new Waypoint("Y", 0.0, 1.0); var z = new Waypoint("Z", 1.0, 3.0); var route = new Route(); route.AddLastWaypoint(x); route.AddLastWaypoint(y, "0"); route.AddLastWaypoint(z, "1"); var expectedDis = x.Distance(y) + y.Distance(z); Assert.AreEqual(expectedDis, route.TotalDistance()); }
public void AddsMainRouteCorrectly() { // Arrange var p1 = new Waypoint("P1", 0.0, 0.0); var p2 = new Waypoint("P2", 0.0, 2.0); var p3 = new Waypoint("P3", 0.0, 4.0); var wptList = new WaypointList(); wptList.AddWaypoint(p1); wptList.AddWaypoint(p2); wptList.AddWaypoint(p3); var route = new Route(); route.AddLastWaypoint(p1); route.AddLastWaypoint(p2, "DCT"); route.AddLastWaypoint(p3, "DCT"); var nodes = new TrackNodes("A", "NATA", route, new WptPair[0]); var adder = new TrackAdder( wptList, wptList.GetEditor(), new StatusRecorder(), TrackType.Nats); // Act adder.AddToWaypointList(new[] { nodes }); // Assert int indexP1 = wptList.FindByWaypoint(p1); Assert.AreEqual(1, wptList.EdgesFromCount(indexP1)); var edge = wptList.EdgesFrom(indexP1).First(); var neighbor = wptList.GetEdge(edge).Value; Assert.IsTrue(neighbor.Airway == "NATA"); Assert.IsTrue(neighbor.InnerWaypoints.SequenceEqual(CreateList(p2))); Assert.AreEqual(InnerWaypointsType.Track, neighbor.Type); var distance = p1.Distance(p2) + p2.Distance(p3); Assert.AreEqual(distance, neighbor.Distance); }
public void AddLastWaypointTest1() { var x = new Waypoint("X", 0.0, 0.0); var y = new Waypoint("Y", 0.0, 1.0); var route = new Route(); route.AddLastWaypoint(x); route.AddLastWaypoint(y, "0", 100.0); Assert.IsTrue(y.Equals(route.LastWaypoint)); Assert.IsTrue("0" == route.Last.Previous.Value.AirwayToNext.Airway); Assert.AreEqual( 100.0, route.Last.Previous.Value.AirwayToNext.Distance, 1E-8); Assert.IsTrue(x.Equals(route.Last.Previous.Value.Waypoint)); }
public void AddLastWaypointTest3EmptyRoute() { var x = new Waypoint("X", 0.0, 0.0); var route = new Route(); route.AddLastWaypoint(x); Assert.IsTrue(x.Equals(route.LastWaypoint)); }
public void ConnectRouteMismatchShouldThrowException() { var x = new Waypoint("X", 0.0, 0.0); var route = new Route(); route.AddLastWaypoint(x); Assert.Throws <ArgumentException>(() => route.Connect(GetRoute1())); }
public void ConnectRouteTest() { var x = new Waypoint("X", 0.0, 0.0); var y = new Waypoint("Y", 0.0, 1.0); var z = new Waypoint("Z", 0.0, 3.0); var route = new Route(); route.AddLastWaypoint(x); route.AddLastWaypoint(y, "0"); var expected = new Route(route); route.Connect(GetRoute1()); expected.AddLastWaypoint(z, "1"); Assert.IsTrue(expected.Equals(route)); }
public void AddFirstWaypointTest1() { var x = new Waypoint("X", 0.0, 0.0); var y = new Waypoint("Y", 0.0, 1.0); var route = new Route(); route.AddLastWaypoint(y); route.AddFirstWaypoint(x, "0", 100.0); Assert.IsTrue(x.Equals(route.FirstWaypoint)); Assert.IsTrue("0" == route.First.Value.Neighbor.Airway); Assert.AreEqual(100.0, route.First.Value.Neighbor.Distance, 1E-8); Assert.IsTrue(y.Equals(route.First.Next.Value.Waypoint)); }