public void AirlineCompanyFacadeFacade_GetAllTickets_TicketsReceived() { Ticket newTicket = null; IList <Ticket> tickets1 = null; IList <Ticket> tickets2 = null; InitDBUnitTest.InitDB(); AdministratorFacade_CreateNewCustomer(); Flight flight1 = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany); ILoggedInCustomerFacade customerFacade = GetCustomerFacade(out LoginToken <Customer> tCustomer); Ticket ticket = customerFacade.PurchaseTicket(tCustomer, flight1); tickets1 = airlineCompanyFacade.GetAllTickets(tAirlineCompany); newTicket = CreateNewTicket(); newTicket.ID = ticket.ID; newTicket.FLIGHT_ID = ticket.FLIGHT_ID; newTicket.CUSTOMER_ID = ticket.CUSTOMER_ID; tickets2 = new List <Ticket>(); tickets2.Add(newTicket); List <Ticket> t1 = (List <Ticket>)tickets1; List <Ticket> t2 = (List <Ticket>)tickets2; Assert.AreNotEqual(tickets1, null); Assert.AreNotEqual(tickets2, null); CollectionAssert.AreEqual(t1, t2); Assert.AreEqual(tickets1[0].ID, tickets2[0].ID); Assert.AreEqual(tickets1[0].FLIGHT_ID, tickets2[0].FLIGHT_ID); Assert.AreEqual(tickets1[0].CUSTOMER_ID, tickets2[0].CUSTOMER_ID); }
public void AirlineCompanyFacadeFacade_UpdateFlight_FlightUpdated() { Flight updatedFlight = null; InitDBUnitTest.InitDB(); Flight flight1 = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany); updatedFlight = new Flight(); updatedFlight.ID = flight1.ID; updatedFlight.AIRLINECOMPANY_ID = flight1.AIRLINECOMPANY_ID; updatedFlight.ORIGIN_COUNTRY_CODE = flight1.ORIGIN_COUNTRY_CODE; updatedFlight.DESTINATION_COUNTRY_CODE = flight1.DESTINATION_COUNTRY_CODE; updatedFlight.DEPARTURE_TIME = TestResource.AirlineCompanyFacade_UpdateFlightDetail_DEPARTURE_TIME; updatedFlight.LANDING_TIME = TestResource.AirlineCompanyFacade_UpdateFlightDetail_LANDING_TIME; updatedFlight.REMANING_TICKETS = TestResource.AirlineCompanyFacade_UpdateFlightDetail_REMANING_TICKETS; updatedFlight.TOTAL_TICKETS = TestResource.AirlineCompanyFacade_UpdateFlightDetail_TOTAL_TICKETS; airlineCompanyFacade.UpdateFlight(tAirlineCompany, updatedFlight); Flight f = airlineCompanyFacade.GetFlightByFlightId(tAirlineCompany, updatedFlight.ID); Assert.AreNotEqual(null, f); Assert.AreEqual(updatedFlight.ID, f.ID); Assert.AreEqual(updatedFlight.AIRLINECOMPANY_ID, f.AIRLINECOMPANY_ID); Assert.AreEqual(updatedFlight.ORIGIN_COUNTRY_CODE, f.ORIGIN_COUNTRY_CODE); Assert.AreEqual(updatedFlight.DESTINATION_COUNTRY_CODE, f.DESTINATION_COUNTRY_CODE); Assert.AreEqual(updatedFlight.LANDING_TIME, f.LANDING_TIME); Assert.AreEqual(updatedFlight.DEPARTURE_TIME, f.DEPARTURE_TIME); Assert.AreEqual(updatedFlight.REMANING_TICKETS, f.REMANING_TICKETS); Assert.AreEqual(updatedFlight.TOTAL_TICKETS, f.TOTAL_TICKETS); }
public void AnonymouseFacade_GetAllFlights_FlightsReceived() { Flight newFlight = null; InitDBUnitTest.InitDB(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); AnonymousUserFacade anonymousFacade = GetAnonymousFacade(); IList <Flight> flights1 = anonymousFacade.GetAllFlights(); newFlight = CreateNewFlight1(); newFlight.ID = flight.ID; newFlight.AIRLINECOMPANY_ID = flight.AIRLINECOMPANY_ID; newFlight.ORIGIN_COUNTRY_CODE = flight.ORIGIN_COUNTRY_CODE; newFlight.DESTINATION_COUNTRY_CODE = flight.DESTINATION_COUNTRY_CODE; IList <Flight> flights2 = new List <Flight>(); flights2.Add(newFlight); List <Flight> f1 = (List <Flight>)flights1; List <Flight> f2 = (List <Flight>)flights2; CollectionAssert.AreEqual(f1, f2); Assert.AreEqual(flights1[0].ID, flights2[0].ID); Assert.AreEqual(flights1[0].AIRLINECOMPANY_ID, flights2[0].AIRLINECOMPANY_ID); Assert.AreEqual(flights1[0].ORIGIN_COUNTRY_CODE, flights2[0].ORIGIN_COUNTRY_CODE); Assert.AreEqual(flights1[0].DESTINATION_COUNTRY_CODE, flights2[0].DESTINATION_COUNTRY_CODE); Assert.AreEqual(flights1[0].DEPARTURE_TIME, flights2[0].DEPARTURE_TIME); Assert.AreEqual(flights1[0].LANDING_TIME, flights2[0].LANDING_TIME); Assert.AreEqual(flights1[0].REMANING_TICKETS, flights2[0].REMANING_TICKETS); Assert.AreEqual(flights1[0].TOTAL_TICKETS, flights2[0].TOTAL_TICKETS); }
public void AirlineCompanyFacadeFacade_GetAllFlights_FlightsReceived() { IList <Flight> flights1 = null; IList <Flight> flights2 = null; Flight newFlight = null; InitDBUnitTest.InitDB(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany); flights1 = airlineCompanyFacade.GetAllFlights(tAirlineCompany); newFlight = CreateNewFlight1(); newFlight.ID = flight.ID; newFlight.AIRLINECOMPANY_ID = flight.AIRLINECOMPANY_ID; newFlight.ORIGIN_COUNTRY_CODE = flight.ORIGIN_COUNTRY_CODE; newFlight.DESTINATION_COUNTRY_CODE = flight.DESTINATION_COUNTRY_CODE; flights2 = new List <Flight>(); flights2.Add(newFlight); List <Flight> f1 = (List <Flight>)flights1; List <Flight> f2 = (List <Flight>)flights2; Assert.AreNotEqual(null, flights1); Assert.AreNotEqual(null, flights2); CollectionAssert.AreEqual(f1, f2); Assert.AreEqual(flights1[0].ID, flights2[0].ID); Assert.AreEqual(flights1[0].AIRLINECOMPANY_ID, flights2[0].AIRLINECOMPANY_ID); Assert.AreEqual(flights1[0].ORIGIN_COUNTRY_CODE, flights2[0].ORIGIN_COUNTRY_CODE); Assert.AreEqual(flights1[0].DESTINATION_COUNTRY_CODE, flights2[0].DESTINATION_COUNTRY_CODE); Assert.AreEqual(flights1[0].DEPARTURE_TIME, flights2[0].DEPARTURE_TIME); Assert.AreEqual(flights1[0].LANDING_TIME, flights2[0].LANDING_TIME); Assert.AreEqual(flights1[0].REMANING_TICKETS, flights2[0].REMANING_TICKETS); Assert.AreEqual(flights1[0].TOTAL_TICKETS, flights2[0].TOTAL_TICKETS); }
public void AnonymousFacade_GetFlightById_FlightFound() { Flight newFlight = null; Flight f = null; InitDBUnitTest.InitDB(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); AnonymousUserFacade anonymousFacade = GetAnonymousFacade(); newFlight = CreateNewFlight1(); newFlight.ID = flight.ID; newFlight.AIRLINECOMPANY_ID = flight.AIRLINECOMPANY_ID; newFlight.ORIGIN_COUNTRY_CODE = flight.ORIGIN_COUNTRY_CODE; newFlight.DESTINATION_COUNTRY_CODE = flight.DESTINATION_COUNTRY_CODE; f = anonymousFacade.GetFlightById(newFlight.ID); Assert.AreNotEqual(f, null); Assert.AreEqual(f.ID, newFlight.ID); Assert.AreEqual(f.AIRLINECOMPANY_ID, newFlight.AIRLINECOMPANY_ID); Assert.AreEqual(f.ORIGIN_COUNTRY_CODE, newFlight.ORIGIN_COUNTRY_CODE); Assert.AreEqual(f.DESTINATION_COUNTRY_CODE, newFlight.DESTINATION_COUNTRY_CODE); Assert.AreEqual(f.DEPARTURE_TIME, newFlight.DEPARTURE_TIME); Assert.AreEqual(f.LANDING_TIME, newFlight.LANDING_TIME); Assert.AreEqual(f.REMANING_TICKETS, newFlight.REMANING_TICKETS); Assert.AreEqual(f.TOTAL_TICKETS, newFlight.TOTAL_TICKETS); }
public void AnonymouseFacade_GetAllAirlineCompanies_AirlineCompaniesReceived() { InitDBUnitTest.InitDB(); AirlineCompany airlineCompany1 = AdministratorFacade_CreateNewAirline1(); AirlineCompany airlineCompany2 = AdministratorFacade_CreateNewAirline2(); AnonymousUserFacade anonymousFacade = GetAnonymousFacade(); IList <AirlineCompany> airlineCompanies1 = anonymousFacade.GetAllAirlineCompanies(); IList <AirlineCompany> airlineCompanies2 = new List <AirlineCompany>(); airlineCompanies2.Add(airlineCompany1); airlineCompanies2.Add(airlineCompany2); List <AirlineCompany> a1 = (List <AirlineCompany>)airlineCompanies1; List <AirlineCompany> a2 = (List <AirlineCompany>)airlineCompanies2; CollectionAssert.AreEqual(a1, a2); Assert.AreEqual(airlineCompanies1[0].ID, airlineCompanies2[0].ID); Assert.AreEqual(airlineCompanies1[0].AIRLINE_NAME, airlineCompanies2[0].AIRLINE_NAME); Assert.AreEqual(airlineCompanies1[0].USER_NAME, airlineCompanies2[0].USER_NAME); Assert.AreEqual(airlineCompanies1[0].PASSWORD, airlineCompanies2[0].PASSWORD); Assert.AreEqual(airlineCompanies1[0].COUNTRY_CODE, airlineCompanies2[0].COUNTRY_CODE); Assert.AreEqual(airlineCompanies1[1].ID, airlineCompanies2[1].ID); Assert.AreEqual(airlineCompanies1[1].AIRLINE_NAME, airlineCompanies2[1].AIRLINE_NAME); Assert.AreEqual(airlineCompanies1[1].USER_NAME, airlineCompanies2[1].USER_NAME); Assert.AreEqual(airlineCompanies1[1].PASSWORD, airlineCompanies2[1].PASSWORD); Assert.AreEqual(airlineCompanies1[1].COUNTRY_CODE, airlineCompanies2[1].COUNTRY_CODE); }
public void CustomerFacade_GetAllMyFlights_FlightsReceived() { AddToLogFile("run CustomerFacade GetAllMyFlights"); InitDBUnitTest.InitDB(); IList<Flight> flights1 = null; IList<Flight> flights2 = null; Customer customer = AdministratorFacade_CreateNewCustomer(); CustomerFacade_CreateNewTicket(); ILoggedInCustomerFacade customerFacade = GetCustomerFacade(out LoginToken<Customer> tCustomer); flights1 = customerFacade.GetAllMyFlights(tCustomer, customer.USER_NAME); Flight newFlight = CreateNewFlight1(); newFlight.ID = flights1[0].ID; newFlight.AIRLINECOMPANY_ID = flights1[0].AIRLINECOMPANY_ID; newFlight.ORIGIN_COUNTRY_CODE = flights1[0].ORIGIN_COUNTRY_CODE; newFlight.DESTINATION_COUNTRY_CODE = flights1[0].DESTINATION_COUNTRY_CODE; flights2 = new List<Flight>(); flights2.Add(newFlight); Assert.AreNotEqual(null, flights1); List <Flight> f1 = (List<Flight>)flights1; List<Flight> f2 = (List<Flight>)flights2; CollectionAssert.AreEqual(f1, f2); Assert.AreEqual(flights1[0].ID, flights2[0].ID); Assert.AreEqual(flights1[0].AIRLINECOMPANY_ID, flights2[0].AIRLINECOMPANY_ID); Assert.AreEqual(flights1[0].ORIGIN_COUNTRY_CODE, flights2[0].ORIGIN_COUNTRY_CODE); Assert.AreEqual(flights1[0].DESTINATION_COUNTRY_CODE, flights2[0].DESTINATION_COUNTRY_CODE); Assert.AreEqual(flights1[0].DEPARTURE_TIME, flights2[0].DEPARTURE_TIME); Assert.AreEqual(flights1[0].LANDING_TIME, flights2[0].LANDING_TIME); Assert.AreEqual(flights1[0].REMANING_TICKETS, flights2[0].REMANING_TICKETS-1); Assert.AreEqual(flights1[0].TOTAL_TICKETS, flights2[0].TOTAL_TICKETS); }
public void FlightAlreadyExist() { InitDBUnitTest.InitDB(); Flight flight1 = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany); airlineCompanyFacade.CreateFlight(tAirlineCompany, flight1); }
public void TicketAlreadyExist() { AddToLogFile("run CustomerFacade TicketAlreadyExist Exception"); InitDBUnitTest.InitDB(); AdministratorFacade_CreateNewCustomer(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInCustomerFacade customerFacade = GetCustomerFacade(out LoginToken<Customer> tCustomer); customerFacade.PurchaseTicket(tCustomer, flight); customerFacade.PurchaseTicket(tCustomer, flight); }
public void AirlineCompanyFacadeFacade_CancelFlight_FlightCanceled() { InitDBUnitTest.InitDB(); Flight flight1 = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany); airlineCompanyFacade.CancelFlight(tAirlineCompany, flight1); Flight flight2 = airlineCompanyFacade.GetFlightByFlightId(tAirlineCompany, flight1.ID); Assert.AreEqual(null, flight2); }
public void AirlineCompanyFacadeFacade_ChangeMyPassword_PasswordChanged() { InitDBUnitTest.InitDB(); AirlineCompany airlineCompany1 = AdministratorFacade_CreateNewAirline1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany); ILoggedInAdministratorFacade administratorFacade = GetAdministratorFacade(out LoginToken <Administrator> tAdministrator); airlineCompanyFacade.ChangeMyPassword(tAirlineCompany, tAirlineCompany.User.PASSWORD, TestResource.AirlineCompanyFacade_NewPassword_PASSWORD); AirlineCompany airlineCompany2 = administratorFacade.GetAirlineCompanyById(tAdministrator, airlineCompany1.ID); Assert.AreNotEqual(null, airlineCompany2); Assert.AreEqual(TestResource.AirlineCompanyFacade_NewPassword_PASSWORD, airlineCompany2.PASSWORD); }
public void CustomerFacade_AddTicket_TicketAdded() { AddToLogFile("run CustomerFacade AddTicket"); InitDBUnitTest.InitDB(); Ticket ticket1 = null; Ticket ticket2 = null; Customer customer = AdministratorFacade_CreateNewCustomer(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInCustomerFacade customerFacade = GetCustomerFacade(out LoginToken<Customer> tCustomer); ticket1 = customerFacade.PurchaseTicket(tCustomer, flight); ticket2 = customerFacade.GetTicketByCustomerUserName(tCustomer, customer.USER_NAME); Assert.AreEqual(ticket1, ticket2); }
public void AnonymousFacade_GetAllFlightsByVacanvy_FlightsReceived() { InitDBUnitTest.InitDB(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); AnonymousUserFacade anonymousFacade = GetAnonymousFacade(); Dictionary <Flight, int> FlightsByVacancy1 = new Dictionary <Flight, int>(); FlightsByVacancy1.Add(flight, flight.REMANING_TICKETS); Dictionary <Flight, int> FlightsByVacancy2 = anonymousFacade.GetAllFlightsByVacancy(); Assert.AreNotEqual(FlightsByVacancy1, null); Assert.AreNotEqual(FlightsByVacancy2, null); CollectionAssert.AreEqual(FlightsByVacancy1, FlightsByVacancy2); Assert.AreEqual(FlightsByVacancy1[flight], FlightsByVacancy2[flight]); }
public void AirlineCompanyFacadeFacade_CreateNewFlight_FlightAdded() { Flight newFlight = null; InitDBUnitTest.InitDB(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> t); newFlight = CreateNewFlight1(); newFlight.ID = flight.ID; newFlight.AIRLINECOMPANY_ID = flight.AIRLINECOMPANY_ID; newFlight.ORIGIN_COUNTRY_CODE = flight.ORIGIN_COUNTRY_CODE; newFlight.DESTINATION_COUNTRY_CODE = flight.DESTINATION_COUNTRY_CODE; Flight f = airlineCompanyFacade.GetFlightByFlightId(t, newFlight.ID); Assert.AreNotEqual(null, f); Assert.AreEqual(newFlight, f); }
public void NoTicketLeft() { AddToLogFile("run CustomerFacade NoTicketLeft Exception"); InitDBUnitTest.InitDB(); Flight newFlight1 = null; AdministratorFacade_CreateNewCustomer(); Flight flight1 = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInCustomerFacade customerFacade = GetCustomerFacade(out LoginToken<Customer> tCustomer); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken<AirlineCompany> tAirlineCompany); newFlight1 = CreateNewFlight1(); newFlight1.ID = flight1.ID; newFlight1.AIRLINECOMPANY_ID = flight1.AIRLINECOMPANY_ID; newFlight1.ORIGIN_COUNTRY_CODE = flight1.ORIGIN_COUNTRY_CODE; newFlight1.DESTINATION_COUNTRY_CODE = flight1.DESTINATION_COUNTRY_CODE; newFlight1.REMANING_TICKETS = 0; airlineCompanyFacade.UpdateRemainingTickets(tAirlineCompany, newFlight1); Flight flight2 = customerFacade.GetFlightByFlightId(tCustomer, newFlight1.ID); customerFacade.PurchaseTicket(tCustomer, flight2); }
public void AirlineCompanyFacadeFacade_ModififyAirlineDetails_DetailsModified() { AirlineCompany newAirlineCompany = null; InitDBUnitTest.InitDB(); AirlineCompany airlineCompany1 = AdministratorFacade_CreateNewAirline1(); ILoggedInAirlineFacade airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany); ILoggedInAdministratorFacade administratorFacade = GetAdministratorFacade(out LoginToken <Administrator> tAdministrator); newAirlineCompany = CreateNewAirlineCompany(); newAirlineCompany.ID = airlineCompany1.ID; newAirlineCompany.AIRLINE_NAME = TestResource.AirlineCompanyFacade_UpdatedName_AIRLINE_NAME; newAirlineCompany.COUNTRY_CODE = airlineCompany1.COUNTRY_CODE; airlineCompanyFacade.ModifyAirlineDetails(tAirlineCompany, newAirlineCompany); AirlineCompany airlineCompany2 = administratorFacade.GetAirlineCompanyById(tAdministrator, newAirlineCompany.ID); Assert.AreNotEqual(null, airlineCompany2); Assert.AreEqual(TestResource.AirlineCompanyFacade_UpdatedName_AIRLINE_NAME, airlineCompany2.AIRLINE_NAME); }
public void CustomerFacade_GetAllFlights_FlightsReceived() { AddToLogFile("run CustomerFacade GetAllFlights"); InitDBUnitTest.InitDB(); IList<Flight> flights1 = null; IList<Flight> flights2 = null; AdministratorFacade_CreateNewCustomer(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInCustomerFacade customerFacade = GetCustomerFacade(out LoginToken<Customer> tCustomer); flights1 = customerFacade.GetAllFlights(tCustomer); flights2 = new List<Flight>(); flights2.Add(flight); List<Flight> f1 = (List<Flight>)flights1; List<Flight> f2 = (List<Flight>)flights2; CollectionAssert.AreEqual(f1, f2); Assert.AreEqual(flights1[0].ID, flights2[0].ID); Assert.AreEqual(flights1[0].AIRLINECOMPANY_ID, flights2[0].AIRLINECOMPANY_ID); Assert.AreEqual(flights1[0].ORIGIN_COUNTRY_CODE, flights2[0].ORIGIN_COUNTRY_CODE); Assert.AreEqual(flights1[0].DESTINATION_COUNTRY_CODE, flights2[0].DESTINATION_COUNTRY_CODE); Assert.AreEqual(flights1[0].DEPARTURE_TIME, flights2[0].DEPARTURE_TIME); Assert.AreEqual(flights1[0].LANDING_TIME, flights2[0].LANDING_TIME); Assert.AreEqual(flights1[0].REMANING_TICKETS, flights2[0].REMANING_TICKETS); Assert.AreEqual(flights1[0].TOTAL_TICKETS, flights2[0].TOTAL_TICKETS); }
public static void InitAdminTest(TestContext testContext) { AddToLogFile("run init db"); InitDBUnitTest.InitDB(); }