static void Main(string[] args) { Console.WriteLine("Welcome to RoutePlanner (" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")"); Console.WriteLine(); var wayPoint = new WayPoint("Windisch", 47.479319847061966, 8.212966918945312); var wpBern = new WayPoint("Bern", 46.9479222, 7.4446085); var wpTripolis = new WayPoint("Tripolis", 32.8084124, 13.1509672); Console.WriteLine(wayPoint.ToString()); Console.WriteLine(wpBern.ToString()); Console.WriteLine(wpTripolis.ToString()); Console.WriteLine("Distance: {0}" , wpBern.Distance(wpTripolis)); var citiesLab2 = new Cities(); citiesLab2.ReadCities("data\\citiesTestDataLab2.txt"); var bern = new WayPoint("Bern", 46.95, 7.44); var tripolis = new WayPoint("Tripolis", 32.876174, 13.187507); double actual = bern.Distance(tripolis); Console.WriteLine(); var findCity = citiesLab2.FindCity("Bern"); if (findCity != null) Console.WriteLine("City {0} was found.", findCity.Name); else Console.WriteLine("City not found."); findCity = citiesLab2.FindCity("Dilli"); if (findCity != null) Console.WriteLine("City {0} was found.", findCity.Name); else Console.WriteLine("City not found."); Console.WriteLine(); Console.WriteLine("Test Routes"); var citiesLab3 = new Cities(); citiesLab3.ReadCities("data\\citiesTestDataLab3.txt"); var reqWatcher = new RouteRequestWatcher(); var routes = new RoutesDijkstra(citiesLab3); routes.RouteRequestEvent += reqWatcher.LogRouteRequests; routes.FindShortestRouteBetween("Bern", "Zürich", TransportModes.Bus); routes.FindShortestRouteBetween("Bern", "Zürich", TransportModes.Bus); routes.ReadRoutes("data\\linksTestDataLab3.txt"); Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public void TestRequestWatcher() { var reqWatch = new RouteRequestWatcher(); var cities = new Cities(); cities.ReadCities(CitiesTestFile); var routes = new RoutesDijkstra(cities); routes.RouteRequestEvent += reqWatch.LogRouteRequests; routes.FindShortestRouteBetween("Bern", "Zürich", TransportModes.Rail); routes.FindShortestRouteBetween("Bern", "Zürich", TransportModes.Rail); routes.FindShortestRouteBetween("Basel", "Bern", TransportModes.Rail); Assert.AreEqual(reqWatch.GetCityRequests("Zürich"), 2); Assert.AreEqual(reqWatch.GetCityRequests("Bern"), 1); Assert.AreEqual(reqWatch.GetCityRequests("Basel"), 0); }