Exemple #1
0
        public void TestTask1_FindRoutes()
        {
            Cities cities = new Cities();
            cities.ReadCities(@"citiesTestDataLab4.txt");
            List<Link> expectedLinks = new List<Link>();
            expectedLinks.Add(new Link(new City("Zürich", "Switzerland", 7000, 1, 2),
                                       new City("Aarau", "Switzerland", 7000, 1, 2), 0));
            expectedLinks.Add(new Link(new City("Aarau", "Switzerland", 7000, 1, 2),
                                       new City("Liestal", "Switzerland", 7000, 1, 2), 0));
            expectedLinks.Add(new Link(new City("Liestal", "Switzerland", 7000, 1, 2),
                                       new City("Basel", "Switzerland", 7000, 1, 2), 0));

            Routes routes = new RoutesFloydWarshall(cities);
            int count = routes.ReadRoutes(@"linksTestDataLab4.txt");

            Assert.AreEqual(11, cities.Count);

            // test available cities
            routes.ExecuteParallel = true;
            List<Link> links = routes.FindShortestRouteBetween("Zürich", "Basel", TransportModes.Rail);

            Assert.IsNotNull(links);
            Assert.AreEqual(expectedLinks.Count, links.Count);

            for (int i = 0; i < links.Count; i++)
            {
                Assert.AreEqual(expectedLinks[i].FromCity.Name, links[i].FromCity.Name);
                Assert.AreEqual(expectedLinks[i].ToCity.Name, links[i].ToCity.Name);
            }


            links = routes.FindShortestRouteBetween("doesNotExist", "either", TransportModes.Rail);
            Assert.IsNull(links);

        }
Exemple #2
0
        public void TestTask2_FindRoutes()
        {
            Cities cities = new Cities();
            cities.ReadCities(@"citiesTestDataLab11.txt");
            List<Link> expectedLinks = new List<Link>();

            Routes routes = new RoutesFloydWarshall(cities);
            int count = routes.ReadRoutes(@"linksTestDataLab11.txt");

            Assert.AreEqual(6372, cities.Count);

            // test available cities
            routes.ExecuteParallel = true;
            List<Link> links = routes.FindShortestRouteBetween("Lyon", "Berlin", TransportModes.Rail);
            routes.ExecuteParallel = false;
            List<Link> links2 = routes.FindShortestRouteBetween("Lyon", "Berlin", TransportModes.Rail);

            Assert.IsNotNull(links);
            Assert.AreEqual(13, links.Count);

        }