Example #1
0
        public void GetTicketsByFlight_FlightHasNoTickets_ReturnNullList()
        {
            LoggedInAirlineFacade airlineFacade = GetAirlineFacade(LoggedInAirlineFacadeTest_Constants.GetTicketsByFlight_FlightHasNoTickets_ReturnNullList_LOGINTOKEN_USERNAME,
                                                                   LoggedInAirlineFacadeTest_Constants.GetTicketsByFlight_FlightHasNoTickets_ReturnNullList_LOGINTOKEN_PASSWORD);
            int flightId = LoggedInAirlineFacadeTest_Constants.GetTicketsByFlight_FlightHasNoTickets_ReturnNullList_FLIGHT_ID;

            List <Ticket> tickets = (List <Ticket>)airlineFacade.GetAllTicketsByFlight(airlineFacade.LoginToken, flightId);

            Assert.AreEqual(0, tickets.Count);
        }
Example #2
0
        public void GetAllTicketsByFlight_FlightHasTickets()
        {
            LoggedInAirlineFacade airlineFacade = GetAirlineFacade(LoggedInAirlineFacadeTest_Constants.GetAllTicketsByFlight_FlightHasTickets_LOGINTOKEN_USERNAME,
                                                                   LoggedInAirlineFacadeTest_Constants.GetAllTicketsByFlight_FlightHasTickets_LOGINTOKEN_PASSWORD);
            int flightId = LoggedInAirlineFacadeTest_Constants.GetAllTicketsByFlight_FlightHasTickets_FLIGHT_ID;

            List <Ticket> tickets = (List <Ticket>)airlineFacade.GetAllTicketsByFlight(airlineFacade.LoginToken, flightId);

            Assert.AreNotEqual(0, tickets.Count);
            foreach (Ticket ticket in tickets)
            {
                Assert.IsNotNull(ticket);
            }
        }
        public IActionResult GetTicketsByFlight(int flightId)
        {
            IActionResult result = SafeExecute(() =>
            {
                int facadeIndex = RetriveFacadeIndex();
                LoggedInAirlineFacade airlineFacade = (LoggedInAirlineFacade)FlyingCenterSystem.FacadeList[facadeIndex];
                List <Ticket> tickets = (List <Ticket>)airlineFacade.GetAllTicketsByFlight(airlineFacade.LoginToken, flightId);
                if (tickets.Count < 1)
                {
                    return(NoContent());
                }
                return(Ok(tickets));
            });

            return(result);
        }
Example #4
0
        public void Remove_Flight_With_Ticket()
        {
            Execute_Test(() =>
            {
                Flight demi_flight         = TestData.Get_Flights_Data()[3];
                demi_flight.AirlineCompany = airline_token.User;
                demi_flight.Id             = 1;

                airline_facade.CancelFlight(airline_token, demi_flight);

                Assert.AreEqual(airline_facade.GetAllFlights(airline_token).Count, 1);

                FlightHistory flightHistory = airline_facade.GetFlightHistoryByOriginalId(airline_token, demi_flight.Id);

                Assert.AreEqual(airline_facade.GetAllTicketsByFlight(airline_token, demi_flight).Count, 0);
                Assert.AreEqual(airline_facade.GetFlightHistoryByOriginalId(airline_token, demi_flight.Id).Id, 1);
            });
        }
Example #5
0
        public void GetTicketsByFlight_FlightBelongsToAnotherCompany_ThrowsException()
        {
            LoggedInAirlineFacade airlineFacade = GetAirlineFacade(LoggedInAirlineFacadeTest_Constants.GetTicketsByFlight_FlightBelongsToAnotherCompany_ThrowsException_LOGINTOKEN_USERNAME,
                                                                   LoggedInAirlineFacadeTest_Constants.GetTicketsByFlight_FlightBelongsToAnotherCompany_ThrowsException_LOGINTOKEN_PASSWORD);
            int           flightId = LoggedInAirlineFacadeTest_Constants.GetTicketsByFlight_FlightBelongsToAnotherCompany_ThrowsException_FLIGHT_ID;
            List <Ticket> tickets;

            Assert.ThrowsException <UnauthorisedActionException>(new Action(() => tickets = (List <Ticket>)airlineFacade.GetAllTicketsByFlight(airlineFacade.LoginToken, flightId)));
        }
Example #6
0
        public void GetAllTicketsByFlight_FlightNotFound_ThrowsException()
        {
            LoggedInAirlineFacade airlineFacade = GetAirlineFacade(LoggedInAirlineFacadeTest_Constants.GetAllTicketsByFlight_FlightNotFound_ThrowsException_LOGINTOKEN_USERNAME,
                                                                   LoggedInAirlineFacadeTest_Constants.GetAllTicketsByFlight_FlightNotFound_ThrowsException_LOGINTOKEN_PASSWORD);
            int           flightId = LoggedInAirlineFacadeTest_Constants.GetAllTicketsByFlight_FlightNotFound_ThrowsException_FLIGHT_ID;
            List <Ticket> tickets;

            Assert.ThrowsException <NullResultException>(new Action(() => tickets = (List <Ticket>)airlineFacade.GetAllTicketsByFlight(airlineFacade.LoginToken, flightId)));
        }