private int BuildAirportJson(Airport sdmAirport, Dictionary <string, int> airportMap, List <ReportAirportJson> jsonList, bool preferIataCodes) { var result = -1; if (sdmAirport != null) { var code = preferIataCodes ? String.IsNullOrEmpty(sdmAirport.IataCode) ? sdmAirport.IcaoCode : sdmAirport.IataCode : String.IsNullOrEmpty(sdmAirport.IcaoCode) ? sdmAirport.IataCode : sdmAirport.IcaoCode; if (!String.IsNullOrEmpty(code)) { if (!airportMap.TryGetValue(code, out result)) { result = jsonList.Count; jsonList.Add(new ReportAirportJson() { Code = code, Name = Describe.Airport(sdmAirport, preferIataCodes, showCode: false, showName: true, showCountry: true) }); airportMap.Add(code, result); } } } return(result); }
public void Describe_Airport_Formats_Airport_Correctly() { var worksheet = new ExcelWorksheetData(TestContext); var airport = new Airport(); airport.IcaoCode = worksheet.EString("Icao"); airport.IataCode = worksheet.EString("Iata"); airport.Name = worksheet.EString("Name"); airport.Country = worksheet.EString("Country"); var result = Describe.Airport(airport, worksheet.Bool("PreferIata"), worksheet.Bool("ShowCode"), worksheet.Bool("ShowName"), worksheet.Bool("ShowCountry")); Assert.AreEqual(worksheet.EString("Result"), result); }
public void Describe_Airport_Returns_Empty_String_If_Passed_Null() { Assert.AreEqual("", Describe.Airport(null, false)); }