public string Get(DateTime relative_to) { List <Flight> activeFlights = new List <Flight>(); bool syncAll = Request.Query.Keys.Contains("sync_all"); foreach (Flight flight in flightsManager.GetAllFlights(relative_to)) { if (ValidAccordingToSyncAll(syncAll, flight) && CheckIfFlightIsRelevant(flight, relative_to)) { activeFlights.Add(flight); } } updateFlightsLocation(relative_to); return(JsonConvert.SerializeObject(activeFlights)); }
public async Task GetAllFlightsWithUnformattedDate_ShouldRaiseFormatException() { FlightsManager manager = new FlightsManager(flightPlanDictStub.Object, serversDictStub.Object, idFromServersDictStub.Object); bool exceptionThrown = false; // Act try { IEnumerable <Flight> response = await manager.GetAllFlights("2020-11aef-27T01:56:22Z", false); } catch (FormatException) { exceptionThrown = true; } // Check if Format Exception has been thrown Assert.True(exceptionThrown); }