//[ExpectedException()] public void CheckNullToken() { Assert.ThrowsException <Exception>(() => { airlineFacade.CancelFlight(null, new Flight()); }); Assert.ThrowsException <Exception>(() => { airlineFacade.GetAllTickets(null); }); Assert.ThrowsException <Exception>(() => { airlineFacade.CreateFlight(null, new Flight()); }); Assert.ThrowsException <Exception>(() => { airlineFacade.UpdateFlight(null, new Flight()); }); Assert.ThrowsException <Exception>(() => { airlineFacade.ChangeMyPassword(null, "old_password", "new_password"); }); Assert.ThrowsException <Exception>(() => { airlineFacade.MofidyAirlineDetails(null, new AirlineCompany()); }); }
public IHttpActionResult GetAllTickets() { LoginToken <AirlineCompany> token = (LoginToken <AirlineCompany>)Request.Properties["User"]; LoggedInAirlineFacade facade = (LoggedInAirlineFacade)(FlyingCenterSystem.GetFlyingCenterSystem().GetFacade(token)); return(Ok(facade.GetAllTickets(token))); }
public void NullUserTriesToGetTicketsException() { FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "dana432", "gdfds"); LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token; LoggedInAirlineFacade facade = (LoggedInAirlineFacade)facadebase; IList <Ticket> list = facade.GetAllTickets(null); }
public IHttpActionResult GetAllTickets() { IList <Ticket> ticketLst = null; bool isAuthorized = false; Action act = () => { isAuthorized = GetInternalLoginTokenInternal <AirlineCompany>(out LoginToken <AirlineCompany> loginTokenAirline); if (isAuthorized) { ticketLst = _loggedInAirlineFacade.GetAllTickets(loginTokenAirline); } }; ProcessExceptions(act); if (!isAuthorized) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, $"Sorry, but you're not an Airline Company. Your accsess is denied."))); } if (ticketLst == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, $"There is no tickets in the system."))); } return(Ok(ticketLst)); }
public void Get_List_Of_Tickets() { Execute_Test(() => { IList <Ticket> tickets = airline_facade.GetAllTickets(airline_token); Assert.AreEqual(tickets.Count, 2); }); }
public IHttpActionResult GetAllTickets() { LoginToken <AirlineCompany> token = GetLoginToken(); IList <Ticket> tickets = facade.GetAllTickets(token); return(Ok(tickets)); }
public void GetAllTickets_Test() { FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "dana432", "gdfds"); LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token; LoggedInAirlineFacade facade = (LoggedInAirlineFacade)facadebase; IList <Ticket> list = facade.GetAllTickets(loginToken); Assert.AreEqual(list.Count, 4); }
public IHttpActionResult GetAllTickets() { var loginToken = GetLoginToken(); if (loginToken == null) { return(Unauthorized()); } return(Json(_facade.GetAllTickets(loginToken))); }
public IHttpActionResult GetAllTickets() { GetLoginToken(); if (AirLineToken != null) { List <Ticket> tickets = F.GetAllTickets(AirLineToken).ToList(); return(Ok(tickets)); } return(NotFound()); }
public IHttpActionResult GetAllTickets() { LoginToken <AirlineCompany> airlineToken = (LoginToken <AirlineCompany>)Request.Properties["airlineToken"]; LoggedInAirlineFacade airlineFacade = (LoggedInAirlineFacade)Request.Properties["airlineFacade"]; IList <Ticket> tickets = airlineFacade.GetAllTickets(airlineToken); if (tickets == null || tickets.Count == 0) { return(NotFound()); } return(Ok(tickets)); }
public async Task <ActionResult <List <Ticket> > > GetAllTickets() { FlightsCenterSystem.GetInstance().login(GetLoginToken().Name, GetLoginToken().Password, out LoginToken <Object> l, out FacadeBase f); facade = f as LoggedInAirlineFacade; token_airline = GetLoginToken(); User u = new UserDAOPGSQL().GetAll().FirstOrDefault(_ => _.Password == token_airline.Password && _.Username == token_airline.Name); token_airline.User = new AirlineDAOPGSQL().GetAll().FirstOrDefault(_ => _.UserId == u.Id); var result = await Task.Run(() => facade.GetAllTickets(token_airline)); return(StatusCode(200, result)); }
public void GetAllTickets() { List <Tickets> expected_tickets = new List <Tickets>();// neec to check what went wrong Tickets a = new Tickets(1, 1); Tickets b = new Tickets(2, 2); a.ID = 1; b.ID = 2; expected_tickets.Add(a); expected_tickets.Add(b); List <Tickets> tickets = (List <Tickets>)loggedInAirline.GetAllTickets(airline); CollectionAssert.AreEqual(expected_tickets, tickets); }
public IHttpActionResult GetAllTickets() { try { if (getCompanyLoginToken().GetAllTickets(companyToken) == null) { return(NotFound()); } return(Ok(airlineCompanyFacade.GetAllTickets(companyToken))); } catch (Exception e) { return(BadRequest(e.Message.ToString())); } }
public void AirlineFacade_GetAllTickets_TicketsFound() { LoggedInAirlineFacade facade = FlyingCenterSystem.GetInstance().Login(TestResource.AIRLINE_USERNAME, TestResource.AIRLINE_PASSWORD, out LoginTokenBase login) as LoggedInAirlineFacade; IList <Ticket> tickets = facade.GetAllTickets(login as LoginToken <AirlineCompany>); Assert.AreNotEqual(null, tickets); for (int i = 0; i < tickets.Count; i++) { Assert.AreEqual(TestResource.ticketsId[i], tickets[i].Id); Assert.AreEqual(TestResource.ticketFlightsId[i], tickets[i].FlightId); Assert.AreEqual(TestResource.ticketsCustomersId[i], tickets[i].CustomerId); } }
public IHttpActionResult GetAllTickets() { GetLoginToken(); try { IList <Ticket> tickets = airlineFacade.GetAllTickets(loginToken); if (tickets.Count == 0) { return(NotFound()); } return(Ok(tickets)); } catch (Exception) { return(BadRequest()); } }
public void GetAllTickets() { UserRepository testUr = new UserRepository("dad", "aes", RolesEnum.admin); Admin testAdmin = new Admin("dav,", "id", 3); FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token, out FacadeBase facade); LoginToken <Admin> myToken = token as LoginToken <Admin>; LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade; myFacade.CreateNewAdmin(myToken, testUr, testAdmin); Country country = new Country("Israel"); myFacade.CreateNewCountry(myToken, country); AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID); UserRepository airlineTestUr = new UserRepository("rad", "ass", RolesEnum.airline); myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country); Flight flight = new Flight(DateTime.Now, DateTime.Now, 50, airlineCompany.ID, country.ID, country.ID); FlyingCenterSystem.GetInstance().TryLogin(airlineTestUr.UserName, airlineTestUr.Password, out ILogin tokenAir, out FacadeBase facadeAir); LoginToken <AirlineCompany> myTokenair = tokenAir as LoginToken <AirlineCompany>; LoggedInAirlineFacade myFacadeAir = facadeAir as LoggedInAirlineFacade; myFacadeAir.CreateFlight(myTokenair, flight); AnonymousUserFacade anonymousUserFacade = new AnonymousUserFacade(); Customer customer = new Customer("asdjkb", "fgh", "adthv", "0506794532", "123479520589243", 2); UserRepository customerUserRepository = new UserRepository("radp", "ass", RolesEnum.customer); anonymousUserFacade.CreateCustomerAndUserRepository(customerUserRepository, customer); FlyingCenterSystem.GetInstance().TryLogin(customerUserRepository.UserName, customerUserRepository.Password, out ILogin tokenCustomer, out FacadeBase facadeCustomer); LoginToken <Customer> myTokencustomer = tokenCustomer as LoginToken <Customer>; LoggedInCustomerFacade loggedInCustomerFacade = facadeCustomer as LoggedInCustomerFacade; loggedInCustomerFacade.PurchaseTicket(myTokencustomer, flight); List <Ticket> tickets = (List <Ticket>)myFacadeAir.GetAllTickets(myTokenair); Assert.IsTrue(tickets.Count > 0); }
public void Remove_Airline_Company_With_Flight_And_Ticket() { Execute_Test(() => { int country_id = administrator_facade.CreateNewCountry(administrator_token, TestData.Get_Countries_Data()[0]); int country_id2 = administrator_facade.CreateNewCountry(administrator_token, TestData.Get_Countries_Data()[1]); int country_id3 = administrator_facade.CreateNewCountry(administrator_token, TestData.Get_Countries_Data()[2]); AirlineCompany demi_airline_company = TestData.Get_AirlineCompanies_Data()[0]; demi_airline_company.CountryId = country_id; long airline_company_id = administrator_facade.CreateNewAirlineCompany(administrator_token, demi_airline_company); demi_airline_company.Id = airline_company_id; system.TryLogin(demi_airline_company.User.UserName, demi_airline_company.User.Password, out ILoginToken token, out FacadeBase facade); LoggedInAirlineFacade airlineFacade = facade as LoggedInAirlineFacade; LoginToken <AirlineCompany> airlineToken = token as LoginToken <AirlineCompany>; Flight demi_flight = TestData.Get_Flights_Data()[0]; long flight_id = airlineFacade.CreateFlight(airlineToken, demi_flight); demi_flight.Id = flight_id; Customer demi_customer = TestData.Get_Customers_Data()[0]; demi_customer.Id = administrator_facade.CreateNewCustomer(administrator_token, demi_customer); system.TryLogin(demi_customer.User.UserName, demi_customer.User.Password, out ILoginToken token2, out FacadeBase facade2); LoggedInCustomerFacade customerFacade = facade2 as LoggedInCustomerFacade; LoginToken <Customer> customerToken = token2 as LoginToken <Customer>; Ticket ticket = customerFacade.PurchaseTicket(customerToken, demi_flight); administrator_facade.RemoveAirline(administrator_token, demi_airline_company); Assert.AreEqual(administrator_facade.GetAllAirlineCompanies().Count, 0); Assert.AreEqual(administrator_facade.GetAllFlights().Count, 0); Assert.AreEqual(airlineFacade.GetAllTickets(airlineToken).Count, 0); Assert.AreEqual(airlineFacade.GetFlightHistoryByOriginalId(airlineToken, demi_flight.Id).Id, 1); Assert.AreEqual(customerFacade.GetTicketHistoryByOriginalId(customerToken, ticket.Id).Id, 1); }); }
public void TestGetAllTicketsOfAirlineAndCancelFlight() { ResetWhatIsNeeded(); FlyingCenterSystem flyingCenterSystem = FlyingCenterSystem.GetFlyingCenterSystem(); //sign in as a airline company LoginToken <AirlineCompany> companyLoginToken = flyingCenterSystem.AttemptLoginAirlineCompany("company", "company"); LoggedInAirlineFacade loggedInAirlineFacade = (LoggedInAirlineFacade)flyingCenterSystem.GetFacade(companyLoginToken); //sign in as admin and add 2 customers LoginToken <Administrator> administratorLoginToken = flyingCenterSystem.AttemptLoginAdministrator("admin", "admin"); LoggedInAdministratorFacade loggedInAdministratorFacade = (LoggedInAdministratorFacade)flyingCenterSystem.GetFacade(administratorLoginToken); loggedInAdministratorFacade.CreateNewCustomer(administratorLoginToken, new Customer(-1, "john", "bravo", "john", "john", "places", "number", "anotherNumber")); loggedInAdministratorFacade.CreateNewCustomer(administratorLoginToken, new Customer(-1, "david", "david", "david", "david", "somewhere", "longnumber", "longnumber")); //create 4 flights DateTime now = DateTime.Now; loggedInAirlineFacade.CreateFlight(companyLoginToken, new Flight(-1, companyLoginToken.User.ID, 1, 2, now.AddHours(1), now.AddHours(2), 10, 10)); loggedInAirlineFacade.CreateFlight(companyLoginToken, new Flight(-1, companyLoginToken.User.ID, 1, 2, now.AddHours(2), now.AddHours(3), 10, 10)); loggedInAirlineFacade.CreateFlight(companyLoginToken, new Flight(-1, companyLoginToken.User.ID, 1, 2, now.AddHours(3), now.AddHours(4), 10, 10)); loggedInAirlineFacade.CreateFlight(companyLoginToken, new Flight(-1, companyLoginToken.User.ID, 1, 2, now.AddHours(4), now.AddHours(5), 10, 10)); IList <Flight> flights = loggedInAirlineFacade.GetFlightsByDestinationCountry(2); //login as 2 customers LoginToken <Customer> customer1 = flyingCenterSystem.AttemptLoginCustomer("john", "john"); LoginToken <Customer> customer2 = flyingCenterSystem.AttemptLoginCustomer("david", "david"); LoggedInCustomerFacade loggedInCustomerFacade = (LoggedInCustomerFacade)flyingCenterSystem.GetFacade(customer1); //purchase tickets loggedInCustomerFacade.PurchaseTicket(customer1, flights[0]); loggedInCustomerFacade.PurchaseTicket(customer1, flights[1]); loggedInCustomerFacade.PurchaseTicket(customer1, flights[2]); loggedInCustomerFacade.PurchaseTicket(customer1, flights[3]); loggedInCustomerFacade.PurchaseTicket(customer2, flights[0]); loggedInCustomerFacade.PurchaseTicket(customer2, flights[1]); //check to see if the flights data has been updated Flight flight0 = loggedInCustomerFacade.GetFlightById(flights[0].ID); Flight flight1 = loggedInCustomerFacade.GetFlightById(flights[1].ID); Flight flight2 = loggedInCustomerFacade.GetFlightById(flights[2].ID); Flight flight3 = loggedInCustomerFacade.GetFlightById(flights[3].ID); Assert.AreEqual(8, flight0.RemainingTickets); Assert.AreEqual(8, flight1.RemainingTickets); Assert.AreEqual(9, flight2.RemainingTickets); Assert.AreEqual(9, flight3.RemainingTickets); //check to see if tickets table has been updated IList <Ticket> tickets = loggedInAirlineFacade.GetAllTickets(companyLoginToken); Assert.IsTrue(LookForTicket(tickets, customer1.User.ID, flight0.ID)); Assert.IsTrue(LookForTicket(tickets, customer1.User.ID, flight1.ID)); Assert.IsTrue(LookForTicket(tickets, customer1.User.ID, flight2.ID)); Assert.IsTrue(LookForTicket(tickets, customer1.User.ID, flight3.ID)); Assert.IsTrue(LookForTicket(tickets, customer2.User.ID, flight0.ID)); Assert.IsTrue(LookForTicket(tickets, customer2.User.ID, flight1.ID)); //remove the flights loggedInAirlineFacade.CancelFlight(companyLoginToken, flight0); loggedInAirlineFacade.CancelFlight(companyLoginToken, flight1); loggedInAirlineFacade.CancelFlight(companyLoginToken, flight2); loggedInAirlineFacade.CancelFlight(companyLoginToken, flight3); tickets = loggedInAirlineFacade.GetAllTickets(companyLoginToken); Assert.IsTrue(tickets.Count == 0); flights = loggedInAirlineFacade.GetAllFlights(companyLoginToken); Assert.IsTrue(flights.Count == 0); }
public void GetAllTickets() { IList <Ticket> tickets = facade.GetAllTickets(AirLineLogin); }