コード例 #1
0
ファイル: Lab10Test.cs プロジェクト: Lesrac/ecnf_labor
        public async Task TestFindShortestRouteBetweenAsynch()
        {
            var cities = new Cities();
            cities.ReadCities(CitiesTestFile);

            var routes = new RoutesDijkstra(cities);
            routes.ReadRoutes(LinksTestFile);

            // do synchronous execution
            linksExpected = 
            routes.FindShortestRouteBetween("Basel", "Zürich", TransportModes.Rail);

            // do asynchronous execution
            linksActual =
             await routes.GoFindShortestRouteBetween("Basel", "Zürich", TransportModes.Rail);

            // not test the results
            Assert.IsNotNull(linksActual);
            Assert.AreEqual(linksExpected.Count, linksActual.Count);


            for (int i = 0; i < linksActual.Count; i++)
            {
                Assert.AreEqual(linksExpected[i].FromCity, linksActual[i].FromCity);
                Assert.AreEqual(linksExpected[i].ToCity, linksActual[i].ToCity);
            }
        }
コード例 #2
0
ファイル: Lab10Test.cs プロジェクト: Lesrac/ecnf_labor
        public async Task TestFindShortestRouteBetweenAsynchProgress()
        {
            var cities = new Cities();
            cities.ReadCities(CitiesTestFile);

            var routes = new RoutesDijkstra(cities);
            routes.ReadRoutes(LinksTestFile);


            var progress = new Progress<string> (ProgressReport);
            // do asynchronous execution
            linksActual =
             await routes.GoFindShortestRouteBetween("Basel", "Zürich", TransportModes.Rail, progress);

            // the following assert has to be made after the routine routine returns 
            // assert, that in minimum 5 progress calls are made
            Assert.IsTrue(progCount >= 5, "less than 5 progress calls");

            // See comment in ProgressReport method
            Assert.IsFalse(doneMissing, String.Format("the progress message <{0}>does not contain <done>", failingMessage));
        }