public AirTicketOfficeContext GetFlightsBookedByCustomer(Customer customer) { AirTicketOfficeContext occupiedCars = new AirTicketOfficeContext(); for (int i = 0; i < context.SizeOfFlight(); i++) { String[] customersId = context.GetFlightByIndex(i).CustomersId; if (context.GetFlightByIndex(i).CustomersId.Length == 0) { continue; } for (int j = 0; j < context.GetFlightByIndex(i).CustomersId.Length; j++) { if (customer.Id.Equals(customersId[j])) { occupiedCars.Flights = AddFlightToArray(occupiedCars, i).Flights; break; } } } if (occupiedCars.Flights.Length == 0) { throw new BookingException("You haven't booked flight."); } logger.Info("Got list of booked by customer flights"); return(occupiedCars); }
public void getAvailableFlightOfNewCustomerByLength() { CustomerController customerController = new CustomerController(); Customer customer = customerController.AddNewCustomerOrGetExisting("Ivan", "ivan_ivanov"); FlightController flightController = new FlightController(); AirTicketOfficeContext context = AirTicketOfficeContext.Context; AirTicketOfficeContext availableFlight = flightController.GetAvailableFlight(customer); Assert.AreEqual(availableFlight.Flights.Length, context.SizeOfFlight()); }