Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MockFlightStatusObservable" /> class.
        /// </summary>
        /// <param name="flightStatusParameters">The parameters to this FlightStatusObservable. Preference is given to the FlightName, followed by AirlineCode+FlightNumber,
        /// then AirlineName+FlightNumber.</param>
        /// <exception cref="System.ArgumentException">Thrown if flightStatusParameters doesn't contain enough information to determine a flight.</exception>
        public MockFlightStatusObservable(FlightStatusParameters flightStatusParameters)
        {
            if (flightStatusParameters == null)
            {
                throw new ArgumentNullException(nameof(flightStatusParameters));
            }

            if (!string.IsNullOrWhiteSpace(flightStatusParameters.FlightName))
            {
                _flightStatusQueryString = flightStatusParameters.FlightName;
            }
            else if (!string.IsNullOrWhiteSpace(flightStatusParameters.FlightNumber))
            {
                if (!string.IsNullOrWhiteSpace(flightStatusParameters.AirlineCode))
                {
                    _flightStatusQueryString = string.Format("{0}{1}", flightStatusParameters.AirlineCode, flightStatusParameters.FlightNumber);
                }
                else if (!string.IsNullOrWhiteSpace(flightStatusParameters.AirlineName))
                {
                    _flightStatusQueryString = string.Format("{0}{1}", flightStatusParameters.AirlineName, flightStatusParameters.FlightNumber);
                }
            }

            if (string.IsNullOrEmpty(_flightStatusQueryString))
            {
                throw new ArgumentException(string.Format("Not enough information in flightStatusParameters to specify a flight: {0}", flightStatusParameters));
            }
        }
#pragma warning restore IDE0052 // Remove unread private members

        public FlightStatusObservable(FlightStatusParameters parameters)
        {
            _parameters = parameters;
        }