public void notTicketBookedByCustomer()
        {
            CustomerController customerController = new CustomerController();
            Customer           customer           = customerController.AddNewCustomerOrGetExisting("Ivan", "ivan_ivanov");
            FlightController   flightController   = new FlightController();

            Assert.Throws <BookingException>(() => flightController.GetFlightsBookedByCustomer(customer));
        }
        public void getTicketsBookedExistingCustomerByLength()
        {
            CustomerController customerController   = new CustomerController();
            int                    isActual         = 2;
            Customer               customer         = customerController.AddNewCustomerOrGetExisting("Helena", "lenka_bokshic");
            FlightController       flightController = new FlightController();
            AirTicketOfficeContext availableFlight  = flightController.GetFlightsBookedByCustomer(customer);

            Assert.AreEqual(availableFlight.Flights.Length, isActual);
        }
Exemplo n.º 3
0
 public static void ChoicebyCustomer(FlightController flightController, Customer customer, int action)
 {
     try
     {
         if (action == 1)
         {
             AirTicketOfficeContext availableFlight = flightController.GetAvailableFlight(customer);
             Printer.print(availableFlight.ToString());
             Printer.print("Choose flight");
             int index = Convert.ToInt32(UserInput.input());
             flightController.BookTicket(availableFlight.Flights[index - 1], customer);
             logger.Info("Ticket is booked");
         }
         else if (action == 2)
         {
             AirTicketOfficeContext occupiedCars = flightController.GetFlightsBookedByCustomer(customer);
             Printer.print(occupiedCars.ToString());
             Printer.print("Choose flight");
             int index = Convert.ToInt32(UserInput.input());
             flightController.ReturnTicket(occupiedCars.Flights[index - 1], customer);
             logger.Info("Ticket is booked");
         }
         else
         {
             throw new InputException("You should enter 1 or 2");
         }
     }
     catch (Exception ex)
     {
         if (ex is BookingException || ex is InputException)
         {
             System.Console.WriteLine($"Error: {ex.Message}");
         }
         logger.Error(ex.Message);
     }
 }