public void FindNearestStation()
        {
            var point = new Point(51.499, -0.275);

            var tubeStations = new LinkedList<TubeStation>();
            tubeStations.AddLast(new TubeStation("Acton Town",
                new Point(51.503071, -0.280303)));
            tubeStations.AddLast(new TubeStation("Chiswick Park",
                new Point(51.494371,-0.267737)));

            var finder = new SequentialTubeStationFinder();

            var expectedNearestTubeStationName = "Acton Town";
            var foundNearestTubeStation = finder.FindNearestTubeStation(tubeStations, point);

            Assert.AreEqual(expectedNearestTubeStationName, foundNearestTubeStation.Name);
        }
Пример #2
0
 public void TearDown()
 {
     actonTown = chiswickPark = null;
 }
Пример #3
0
 public void SetUp()
 {
     actonTown = new Point(51.503071, -0.280303);
     chiswickPark = new Point(51.494371, -0.267737);
 }
 public TubeStation FindNearestTubeStation(ICollection<TubeStation> tubeStations, Point point)
 {
     return (from tubeStation in tubeStations
             orderby tubeStation.Point.Distance(point)
             select tubeStation).First();
 }