public async Task FlightRepository_GetFlightByFlightNumber_Success() { Flight flight = await _repository.GetFlightByFlightNumber(1, 2, 2); Assert.IsNotNull(flight); Flight dbFlight = await _context.Flights.FirstAsync(f => f.FlightNumber == 1); Assert.IsNotNull(dbFlight); Assert.AreEqual(dbFlight.FlightNumber, flight.FlightNumber); Assert.AreEqual(dbFlight.Origin, flight.Origin); Assert.AreEqual(dbFlight.Destination, flight.Destination); }
private async Task <bool> FlightExistsInDatabase(int flightNumber) { try { return(await _flightRepository.GetFlightByFlightNumber(flightNumber) != null); } catch (FlightNotFoundException) { return(false); } }
public virtual async Task <FlightView> GetFlightByFlightNumber(int flightNumber) { try { Flight flight = await _flightRepository.GetFlightByFlightNumber(flightNumber); Airport originAirport = await _airportRepository.GetAirportByID(flight.Origin); Airport destinationAirport = await _airportRepository.GetAirportByID(flight.Destination); return(new FlightView(flight.FlightNumber.ToString(), (originAirport.City, originAirport.Iata), (destinationAirport.City, destinationAirport.Iata))); } catch (FlightNotFoundException) { throw new FlightNotFoundException(); } catch (Exception) { throw new ArgumentException(); } }
public async Task GetFlightByFlightNumber_Failure_InvalidFlightNumber() { await _repository.GetFlightByFlightNumber(-1); }
public async Task GetFlightByFlightNumber_Failure_InvalidOriginAirportId() { await _repository.GetFlightByFlightNumber(0, -1, 0); }