public ActionResult <IEnumerable <Person> > GetPassengersByFlight([FromQuery] string flightNumber)
        {
            if (string.IsNullOrEmpty(flightNumber))
            {
                var errorMessage = "Flight number should be specified";
                _logger.LogError(errorMessage, HttpContext.Request.Path);

                return(BadRequest(new { ErrorMessage = errorMessage }));
            }

            return(Ok(_passengersService.GetPassengersByFlight(flightNumber)));
        }
示例#2
0
        public void GetAllPassengersByFlightNumber_ShouldReturnAllPassengersOnSpecificFlight()
        {
            // Arrange
            var testPassengers = _mockBookingRepository.Object.GetAll()
                                 .Where(b => b.Flight.Number == "PZ696")
                                 .SelectMany(p => p.Passengers)
                                 .ToList();

            // Act
            var result = _passengersService.GetPassengersByFlight("PZ696").ToList();

            // Assert
            Assert.AreEqual(testPassengers.Count, result.Count);
        }