Ejemplo n.º 1
0
        public void TestFindNeighboursSorted()
        {
            var cities = new Cities();
            cities.ReadCities(CitiesTestFile);

            var loc = cities[0].Location;

            var neighbors = cities.FindNeighbours(loc, 2000);

            Assert.AreEqual(4, neighbors.Count);

            //verify the correct order (sorted  by distance)
            Assert.AreEqual("Mumbai", neighbors[0].Name);
            Assert.AreEqual("Karachi", neighbors[1].Name);
            Assert.IsTrue(loc.Distance(neighbors[0].Location) <= loc.Distance(neighbors[1].Location));
            Assert.AreEqual("Dilli", neighbors[2].Name);
            Assert.IsTrue(loc.Distance(neighbors[1].Location) <= loc.Distance(neighbors[2].Location));
            Assert.AreEqual("Dhaka", neighbors[3].Name);
            Assert.IsTrue(loc.Distance(neighbors[2].Location) <= loc.Distance(neighbors[3].Location));
        }
Ejemplo n.º 2
0
        public void TestFindNeighbours()
        {
            var cities = new Cities();
            cities.ReadCities(CitiesTestFile);

            var loc = cities[0].Location;

            var neighbors = cities.FindNeighbours(loc, 2000);

            Assert.AreEqual(4, neighbors.Count);

            //verifies if the correct cities were found
            Assert.IsNotNull(neighbors.First(c=>c.Name == "Mumbai"));
            Assert.IsNotNull(neighbors.First(c => c.Name == "Karachi"));
            Assert.IsNotNull(neighbors.First(c => c.Name == "Dhaka"));
            Assert.IsNotNull(neighbors.First(c => c.Name == "Dilli"));
        }