Example #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));
 }
 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);
 }
Example #4
0
        public void LoadFlightsFromAirport(Airport airport)
        {
            Arrivals.Clear();
            Departures.Clear();

            _flightsService.GetFlightsFrom(FlightsLoaded, _selectedAirport);
        }
        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();
        }
Example #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));
        }
        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();
        }
Example #10
0
        public void Can_display_airport_as_string()
        {
            var airport = new Airport("LKL", "Lakselv");

            Assert.AreEqual("LKL - Lakselv", airport.ToString());
        }
 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);
 }
Example #12
0
 private void OnAirportSelected(AirportSelectedMessage message)
 {
     SelectedAirport = message.Content;
 }
Example #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;
         }
     }
 }
Example #14
0
 public Flight(Airline airline, Airport airport)
 {
     Airline = airline;
     Airport = airport;
     FlightStatus = new FlightStatus();
 }