예제 #1
0
        public void Can_determine_that_two_airports_are_equal()
        {
            var airport1 = new Airport("LKL", "Lakselv");
            var airport2 = new Airport("LKL", "Lakselv");

            Assert.AreEqual(airport1, airport2);
        }
 public void GetFlightsFrom(Action<Result<IEnumerable<Flight>>> callback, Airport fromAirport)
 {
     var flights = new List<Flight>();
     flights.AddRange(CreateFlights(6, Direction.Arrival));
     flights.AddRange(CreateFlights(6, Direction.Depature));
     callback(new Result<IEnumerable<Flight>>(flights));
 }
예제 #3
0
 public void Can_delete_an_object()
 {
     var airport = new Airport("LKL", "Lakselv");
     _objectStore.Save(airport, Airport.SelectedAirportFilename);
     _objectStore.Delete(Airport.SelectedAirportFilename);
     _objectStore.Load<Airport>(Airport.SelectedAirportFilename);
 }
예제 #4
0
        public void LoadFlightsFromAirport(Airport airport)
        {
            Arrivals.Clear();
            Departures.Clear();

            _flightsService.GetFlightsFrom(FlightsLoaded, _selectedAirport);
        }
예제 #5
0
        private void LoadSelectedAirportFromDisk()
        {
            if (!_objectStore.FileExists(Airport.SelectedAirportFilename)) return;

            var savedAirport = _objectStore.Load<Airport>(Airport.SelectedAirportFilename);
            SelectedAirport = Airports.Where(a => a.Code == savedAirport.Code).Single();
        }
예제 #6
0
        public void Can_get_distance_to_airport()
        {
            var altaAirport = new Airport("ALF", "Alta", 69.9792675, 23.3570997);
            var home = new Location(63.433281, 10.419294);
            var distance = altaAirport.DistanceFrom(home);

            Assert.IsTrue(distance > 670);
        }
        public void GetFlightsFrom(Action<Result<IEnumerable<Flight>>> callback, Airport fromAirport)
        {
            FromAirport = fromAirport;
            GetFlightsFromWasCalled = true;

            callback(ExceptionToBeThrown == null
                         ? new Result<IEnumerable<Flight>>(GetFlights())
                         : new Result<IEnumerable<Flight>>(ExceptionToBeThrown));
        }
예제 #8
0
        public void Can_persist_a_simple_object()
        {
            var airport = new Airport("LKL", "Lakselv");

            _objectStore.Save(airport, Airport.SelectedAirportFilename);
            var airportRead = _objectStore.Load<Airport>(Airport.SelectedAirportFilename);

            Assert.AreEqual(airport.Code, airportRead.Code);
            Assert.AreEqual(airport.Name, airportRead.Name);
        }
        public void Can_get_flights_from_Oslo_airport()
        {
            var flightsList = new List<Flight>();
            var osl = new Airport("OSL", "Oslo");

            EnqueueCallback(() => _service.GetFlightsFrom(r => flightsList.AddRange(r.Value), osl));
            EnqueueConditional(() => flightsList.Count > 0);
            EnqueueCallback(() => AssertThatFlightsAreLoaded(flightsList));
            EnqueueCallback(() => Assert.IsTrue(_service.Airports.Count > 0));
            EnqueueCallback(() => Assert.IsTrue(_service.Airlines.Count > 0));
            EnqueueCallback(() => Assert.IsTrue(_service.Statuses.Count > 0));

            EnqueueTestComplete();
        }
예제 #10
0
        public void Can_display_airport_as_string()
        {
            var airport = new Airport("LKL", "Lakselv");

            Assert.AreEqual("LKL - Lakselv", airport.ToString());
        }
예제 #11
0
 public void Setup()
 {
     _lakselvAirport = new Airport("LKL", "Lakselv");
     _trondheimAirport = new Airport("TRD", "Trondheim");
     _flightsService = new FlightsServiceStub();
     _objectStore = new ObjectStoreStub();
     _messenger = new TinyMessengerHub();
     _dispatcher = new DispatchAdapter();
     _viewModel = new FlightsViewModel(_flightsService, _objectStore, _messenger, _dispatcher);
 }
예제 #12
0
 private void OnAirportSelected(AirportSelectedMessage message)
 {
     SelectedAirport = message.Content;
 }
예제 #13
0
 private void LoadSelectedAirport()
 {
     if (_objectStore.FileExists("SelectedAirport"))
     {
         var airport = _objectStore.Load<Airport>("SelectedAirport");
         if (airport.Equals(Airport.Nearest))
         {
             _messenger.Publish(new FindNearestAirportMessage(this));
         }
         else
         {
             SelectedAirport = airport;
         }
     }
 }
예제 #14
0
 public Flight(Airline airline, Airport airport)
 {
     Airline = airline;
     Airport = airport;
     FlightStatus = new FlightStatus();
 }