internal AnonymousUserFacade() { LoginToken = null; _airlineDAO = new AirlineDAOMSSQL(); _flightDAO = new FlightDAOMSSQL(); _countryDAO = new CountryDAOMSSQL(); }
public void CountryFuncsTest() { FlightDAOMSSQL flight = new FlightDAOMSSQL(); flight.RemoveAll(); CountryDAOMSSQL c = new CountryDAOMSSQL(); c.RemoveAll(); AirlineDAOMSSQL airline = new AirlineDAOMSSQL(); airline.RemoveAll(); Country c1, c2; c1 = new Country("UAE"); c2 = new Country("England"); CountryDAOMSSQL country = new CountryDAOMSSQL(); country.RemoveAll(); country.Add(c1); country.Add(c2); country.Remove(c2); IList <Country> countries = country.GetAll(); Country updatedCountry = country.Get(c1.Id); updatedCountry.CountryName = "Spain"; country.Update((updatedCountry)); Assert.AreEqual(updatedCountry, countries[0]); }
public void CustomersFuncsTest() { FlightDAOMSSQL flight = new FlightDAOMSSQL(); flight.RemoveAll(); CountryDAOMSSQL c = new CountryDAOMSSQL(); c.RemoveAll(); AirlineDAOMSSQL airline = new AirlineDAOMSSQL(); airline.RemoveAll(); Customer cust1 = new Customer("gal", "mazana", "userrr", "123", "afula", "0526614430", "4580982574849111"); Customer cust2 = new Customer("hamody", "zoubi", "hahaaaaa", "321", "ein harod", "0954542323521", "6528429299292"); CustomerDAOMSSQL customer = new CustomerDAOMSSQL(); customer.RemoveAll(); customer.Add(cust1); customer.Add(cust2); customer.Remove(cust2); Customer upddatedCust = customer.Get(cust1.Id); upddatedCust.UserName = "******"; customer.Update(upddatedCust); IList <Customer> customers = customer.GetAll(); Assert.AreEqual(customers[0], customer.Get(cust1.Id)); }
public void AirlineFuncsTest() { FlightDAOMSSQL flight = new FlightDAOMSSQL(); flight.RemoveAll(); CountryDAOMSSQL c = new CountryDAOMSSQL(); c.RemoveAll(); AirlineDAOMSSQL airline = new AirlineDAOMSSQL(); airline.RemoveAll(); AirlineCompany company1 = new AirlineCompany("elal", "elel", "123", 4); AirlineCompany company2 = new AirlineCompany("turkishairline", "ttt", "123", 3); AirlineDAOMSSQL aIrLine = new AirlineDAOMSSQL(); aIrLine.RemoveAll(); aIrLine.Add(company1); aIrLine.Add(company2); aIrLine.Remove(company1); AirlineCompany updatedAirlineCompany = aIrLine.Get(company2.Id); updatedAirlineCompany.Username = "******"; aIrLine.Update(updatedAirlineCompany); IList <AirlineCompany> companies = aIrLine.GetAll(); Assert.AreEqual(updatedAirlineCompany, aIrLine.GetAirlineByUserName(updatedAirlineCompany.Username)); }
public void CancelTicket(LoginToken <Customer> token, Tickets ticket) { if (token != null) { _flightDAO = new FlightDAOMSSQL(); _ticketDAO.Remove(ticket); } }
public void UpdateFlight(LoginToken <AirlineCompany> token, Flight flight) { if (token != null) { _flightDAO = new FlightDAOMSSQL(); _flightDAO.Update(flight); } }
{/// <summary> /// This class handle connecttion to Dao Anonymous functions /// </summary> public AnonymousUserFacade() { _flightDAO = new FlightDAOMSSQL(); _airlineDAO = new AirLineDAOMSSQL(); _administratorDAO = new AdministratorDAOMSSQL(); _ticketDAO = new TicketDAOMSSQL(); _customerDAO = new CustomerDAOMMSQL(); _countryDAO = new CountryDAOMSSQL(); }
public List <Flight> GetAllFlights(LoginToken <AirlineCompany> token) { List <Flight> resList = new List <Flight>(); if (token != null) { _flightDAO = new FlightDAOMSSQL(); resList = _flightDAO.GetAll(); } return(resList); }
public void UpdateFlightTest() { t.ClearDataBase(); Flight flight = t.CreateFlightForTests(); FlightDAOMSSQL DAO = new FlightDAOMSSQL(); Assert.AreEqual(DAO.Get(flight.ID).REMAINGING_TICKETS, flight.REMAINGING_TICKETS); flight.REMAINGING_TICKETS = 200; t.airlinecompanyFacade.UpdateFlight(t.airlinecompanyToken, flight); Assert.AreEqual(DAO.Get(flight.ID).REMAINGING_TICKETS, flight.REMAINGING_TICKETS); }
public List <Flight> GetAllMyFlights(LoginToken <Customer> token) { List <Flight> flights = new List <Flight>(); if (token != null) { _flightDAO = new FlightDAOMSSQL(); flights = _flightDAO.GetAll(); } return(flights); }
public void UpdateFlightTest() { Flight Flight = new Flight(TestCenter.AirlineToken.User.Id, TestCenter.AirlineToken.User.CountryCode, TestCenter.AirlineToken.User.CountryCode, new DateTime(2020, 10, 10, 10, 00, 00), new DateTime(2020, 10, 11, 10, 00, 00), 100); TestCenter.AirlineFacade.CreateFlight(TestCenter.AirlineToken, Flight); FlightDAOMSSQL F = new FlightDAOMSSQL(); Flight.RemainingTickets = 200; Assert.AreNotEqual(F.Get(Flight.Id).RemainingTickets, Flight.RemainingTickets); TestCenter.AirlineFacade.UpdateFlight(TestCenter.AirlineToken, Flight); Assert.AreEqual(F.Get(Flight.Id).RemainingTickets, Flight.RemainingTickets); }
public void TestCreateFlight() { test = new TestInfo(); Country testCountry = new Country("usa"); testCountry.ID = test.adminF.CreateNewCountry(test.adminT, testCountry); Flight flight = new Flight(test.airlineT.User.ID, testCountry.ID, testCountry.ID, DateTime.ParseExact("2019-07-08 12:00:00", "yyyy-MM-dd HH:mm:ss", null), DateTime.ParseExact("2019-07-18 12:00:00", "yyyy-MM-dd HH:mm:ss", null), 5); FlightDAOMSSQL Fdao = new FlightDAOMSSQL(); flight.ID = Fdao.ADD(flight); Assert.AreEqual(flight.AirLineCompanyID, test.airlineF.GetFlightById(flight.ID).AirLineCompanyID); }
public RandomDataGenerator() { _random = new Random(); _countryDAO = new CountryDAOMSSQL(); _customerDAO = new CustomerDAOMSSQL(); _airlineDAO = new AirlineDAOMSSQL(); _flightDAO = new FlightDAOMSSQL(); _ticketDAO = new TicketDAOMSSQL(); _countries = new List <Country>(); _customers = new List <Customer>(); _airlineCompanies = new List <AirlineCompany>(); _flights = new List <Flight>(); _tickets = new List <Ticket>(); }
public void TestGetAllflightsAirlineFacade() { test = new TestInfo(); Country testCountry = new Country("usa"); testCountry.ID = test.adminF.CreateNewCountry(test.adminT, testCountry); Flight flight = new Flight(test.airlineT.User.ID, testCountry.ID, testCountry.ID, DateTime.ParseExact("2019-07-08 12:00:00", "yyyy-MM-dd HH:mm:ss", null), DateTime.ParseExact("2019-07-18 12:00:00", "yyyy-MM-dd HH:mm:ss", null), 5); FlightDAOMSSQL Fdao = new FlightDAOMSSQL(); flight.ID = Fdao.ADD(flight); IList <Flight> flights = test.airlineF.GetAllFlights(); Assert.AreEqual(flights.Count, 1); }
private void _timer_Elapsed(object sender) { string time = ConfigurationManager.AppSettings["ClearHistoryTime"]; int hour = Convert.ToInt32(time); int now = DateTime.Now.Hour; if (now >= hour) { TIcketDAOMSSQL t = new TIcketDAOMSSQL(); FlightDAOMSSQL f = new FlightDAOMSSQL(); t.MoveToTicketHistory(); f.MoveToFlightsHistory(); } }
public IList <Flight> GetAllMyFlights(LoginToken <CustomerLogin> token) { IList <Flight> list = new List <Flight>(); _flightDAO = new FlightDAOMSSQL(); if (token.User.GetCustomer()) { list = _flightDAO.GetAll(); return(list); } else { return(null); } }
public void TestCancelTicket() { test = new TestInfo(); Country testCountry = new Country("usa"); testCountry.ID = test.adminF.CreateNewCountry(test.adminT, testCountry); Flight flight = new Flight(test.airlineT.User.ID, testCountry.ID, testCountry.ID, DateTime.ParseExact("2019-07-08 12:00:00", "yyyy-MM-dd HH:mm:ss", null), DateTime.ParseExact("2019-07-18 12:00:00", "yyyy-MM-dd HH:mm:ss", null), 5); FlightDAOMSSQL Fdao = new FlightDAOMSSQL(); flight.ID = Fdao.ADD(flight); Ticket t = test.customerF.PurchaseTicket(test.customerT, flight); TicketDAOMSSQL tDAO = new TicketDAOMSSQL(); test.customerF.CancelTicket(test.customerT, t); Assert.AreEqual(0, tDAO.Get(t.ID).ID); }
public void AirlineFacadeTest() { FlightCenterConfig.DeleteDataBase(); CountryDAOMSSQL cydao = new CountryDAOMSSQL(); cydao.Add(new Country { COUNTRY_NAME = "Israel" }); long countryId1 = cydao.GetCountryId("Israel"); cydao.Add(new Country { COUNTRY_NAME = "Germany" }); long countryId2 = cydao.GetCountryId("Germany"); AirLineDAOMSSQL adao = new AirLineDAOMSSQL(); adao.Add(new AirlineCompany { AIRLINE_NAME = "IsrLines", USER_NAME = "ISR91", PASSWORD = "******", COUNTRY_CODE = countryId1 }); long airlineCompanyId1 = adao.GetAirlineCompanyId("ISR91"); adao.Add(new AirlineCompany { AIRLINE_NAME = "British Airlines", USER_NAME = "British555", PASSWORD = "******", COUNTRY_CODE = countryId2 }); long airlineCompanyId2 = adao.GetAirlineCompanyId("British555"); LoginToken <AirlineCompany> airlineLogin = new LoginToken <AirlineCompany>(); airlineLogin.User = new AirlineCompany(); airlineLogin.User.USER_NAME = "airline4life"; airlineLogin.User.PASSWORD = "******"; LoggedInAirlineFacade airlineFacade = new LoggedInAirlineFacade(); Flight flight = new Flight(airlineCompanyId1, airlineCompanyId2, countryId1, new DateTime(2019, 05, 10, 10, 30, 00), new DateTime(2019, 05, 10, 15, 05, 00), 15, "HajajaOnile", "555"); airlineFacade.CreateFlight(airlineLogin, flight); FlightDAOMSSQL fdao = new FlightDAOMSSQL(); long flightid = fdao.GetFlightId("555"); Assert.AreEqual(flight, airlineFacade.GetFlightById((int)flightid)); airlineFacade.CancelFlight(airlineLogin, flight); Assert.IsNotNull(airlineFacade.GetFlightById((int)flightid)); airlineFacade.ChangeMyPassword(airlineLogin, "Na123456", "Aa100200"); Assert.AreEqual("Aa100200", airlineLogin.User.PASSWORD); }
public void TestNoMoreTicketsException() { test = new TestInfo(); Country testCountry = new Country("usa"); Country testCountry2 = new Country("russia"); testCountry.ID = test.adminF.CreateNewCountry(test.adminT, testCountry); testCountry2.ID = test.adminF.CreateNewCountry(test.adminT, testCountry2); AirLineCompany a = new AirLineCompany("amrican", "amrican", "12345", testCountry.ID); a.ID = test.adminF.CreateNewAirline(test.adminT, a); Flight flight = new Flight(a.ID, testCountry.ID, testCountry2.ID, DateTime.ParseExact("2019-07-08 12:00:00", "yyyy-MM-dd HH:mm:ss", null), DateTime.ParseExact("2019-07-18 12:00:00", "yyyy-MM-dd HH:mm:ss", null), 0); FlightDAOMSSQL Fdao = new FlightDAOMSSQL(); flight.ID = Fdao.ADD(flight); test.customerF.PurchaseTicket(test.customerT, flight); }
public void CancelFlight(LoginToken <AirlineCompany> token, Flight flight) { if (token != null) { if (flight.REMAINING_TICKETS > 0) { Tickets t = new Tickets(); t = _ticketDAO.GetTicketByFlightId((int)flight.ID); _ticketDAO.Remove(t); } if (flight.REMAINING_TICKETS == 0) { _flightDAO = new FlightDAOMSSQL(); _flightDAO.Remove(flight); } } }
public void TestUpdadteFlight() { test = new TestInfo(); Country testCountry1 = new Country("usa"); Country testCountry2 = new Country("italy"); testCountry1.ID = test.adminF.CreateNewCountry(test.adminT, testCountry1); testCountry2.ID = test.adminF.CreateNewCountry(test.adminT, testCountry2); Flight flight = new Flight(test.airlineT.User.ID, testCountry1.ID, testCountry2.ID, DateTime.ParseExact("2019-07-08 07:00:00", "yyyy-MM-dd HH:mm:ss", null), DateTime.ParseExact("2019-07-18 17:00:00", "yyyy-MM-dd HH:mm:ss", null), 5); flight.ID = test.airlineF.CreateFlight(test.airlineT, flight); FlightDAOMSSQL Fdao = new FlightDAOMSSQL(); flight.RemaniningTickets = 4; Assert.AreNotEqual(Fdao.Get(flight.ID).RemaniningTickets, flight.RemaniningTickets); test.airlineF.UpdateFlight(test.airlineT, flight); Assert.AreEqual(Fdao.Get(flight.ID).RemaniningTickets, flight.RemaniningTickets); }
public Tickets PurchaseTicket(LoginToken <Customer> token, Flight flight) { Tickets ticket = new Tickets(); Flight newFlight = new Flight(flight.AIRLINECOMPANY_ID, flight.ORIGIN_COUNTRY_CODE, flight.DESTINATION_COUNTRY_CODE, flight.DEPARTURE_TIME, flight.LANDING_TIME, flight.REMAINING_TICKETS, flight.AIRLINECOMPANY_NAME, flight.FLIGHT_NAME); if (token != null) { _flightDAO = new FlightDAOMSSQL(); if (newFlight.REMAINING_TICKETS > 0) { newFlight.REMAINING_TICKETS--; _flightDAO.Update(newFlight); } long flightID = _flightDAO.GetFlightId(flight.FLIGHT_NAME); ticket.FLIGHT_ID = flightID; } return(ticket); }
public void TicketFuncsTest() { FlightDAOMSSQL flight = new FlightDAOMSSQL(); flight.RemoveAll(); CountryDAOMSSQL c = new CountryDAOMSSQL(); c.RemoveAll(); AirlineDAOMSSQL airline = new AirlineDAOMSSQL(); airline.RemoveAll(); Ticket t1 = new Ticket(2, 3); Ticket t2 = new Ticket(4, 1); TicketDAOMSSQL ticket = new TicketDAOMSSQL(); //ticket.RemoveAll(); //ticket.Add(t1); //ticket.Add(t2); }
public void AnonymousrFacadeTest() { FlightDAOMSSQL flightsHandler = new FlightDAOMSSQL(); flightsHandler.RemoveAll(); #region filling the flights table CountryDAOMSSQL c = new CountryDAOMSSQL(); c.RemoveAll(); AirlineDAOMSSQL airline = new AirlineDAOMSSQL(); airline.RemoveAll(); Country c1 = new Country("israel"); c.Add(c1); AirlineCompany airline1 = new AirlineCompany("eldal", "maher", "123", c1.Id); airline.Add(airline1); DateTime t = new DateTime(2019, 05, 05, 21, 22, 44); DateTime t1 = new DateTime(2019, 08, 29, 22, 33, 22); Debug.WriteLine(t1.ToString("MM/dd/yy H:mm:ss")); Flight f1 = new Flight(airline1.Id, c1.Id, c1.Id, t, t1, 22); flightsHandler.Add(f1); #endregion FlyingCenterSystem centerSystem = new FlyingCenterSystem(); AnonymouseUserFacade anonymusefacade = centerSystem.OpenLogInSystem(); Assert.IsNotNull(anonymusefacade); IList <AirlineCompany> listcomapny = anonymusefacade.GetAllAirlineCompanies(); IList <Flight> flightsList = anonymusefacade.GetAllFlights(); Assert.AreEqual(f1, flightsList[0]); Dictionary <Flight, int> valuePairs = anonymusefacade.GetAllFlightsVacancy(); Assert.AreEqual(f1.RemainingTickets, valuePairs[f1]); Flight flightsById = anonymusefacade.GetFlightById(f1.Id); Assert.AreEqual(f1, flightsById); IList <Flight> FlightsByDtime = anonymusefacade.GetFlightsByDepartureDate(f1.DepartureTime); Assert.AreEqual(f1, FlightsByDtime[0]); IList <Flight> flighsByDesCountryList = anonymusefacade.GetFlightsByDestionationCountry(f1.DistinationCountryCode); Assert.AreEqual(f1, flighsByDesCountryList[0]); IList <Flight> FlightsByLandingTimeList = anonymusefacade.GetFlightsByLandingeDate(f1.LandingTime); Assert.AreEqual(f1, FlightsByLandingTimeList[0]); IList <Flight> FlightsByOriginCountry = anonymusefacade.GetFlightsByOriginCountry(f1.OriginCountryCode); Assert.AreEqual(f1, FlightsByOriginCountry[0]); }
public void TestInitialize() { airlineDAO = new AirlineDAOMSSQL(); AirlineDAOMSSQL._connectionString = MyConfig._replicaConnectionString; ticketDAO = new TicketDAOMSSQL(); TicketDAOMSSQL._connectionString = MyConfig._replicaConnectionString; flightDAO = new FlightDAOMSSQL(); FlightDAOMSSQL._connectionString = MyConfig._replicaConnectionString; administratorDAO = new AdministratorDAOMSSQL(); AdministratorDAOMSSQL._connectionString = MyConfig._replicaConnectionString; customerDAO = new CustomerDAOMSSQL(); CustomerDAOMSSQL._connectionString = MyConfig._replicaConnectionString; countryDAO = new CountryDAOMSSQL(); CountryDAOMSSQL._connectionString = MyConfig._replicaConnectionString; centerSystem = FlightCenterSystem.GetInstance(); airlineDAO.RemoveAllReplica(); ticketDAO.RemoveAllReplica(); countryDAO.RemoveAllReplica(); flightDAO.RemoveAllReplica(); customerDAO.RemoveAllReplica(); administratorDAO.RemoveAllReplica(); }
public void FlightFuncsTest() { FlightDAOMSSQL flight = new FlightDAOMSSQL(); flight.RemoveAll(); CountryDAOMSSQL c = new CountryDAOMSSQL(); c.RemoveAll(); AirlineDAOMSSQL airline = new AirlineDAOMSSQL(); airline.RemoveAll(); Country c1 = new Country("israel"); c.Add(c1); AirlineCompany airline1 = new AirlineCompany("eldal", "maher", "123", c1.Id); airline.Add(airline1); DateTime t = DateTime.Now; DateTime t1 = new DateTime(2019, 8, 20, 22, 33, 22); Flight f1 = new Flight(airline1.Id, c1.Id, c1.Id, t, t1, 22); flight.Add(f1); Assert.AreEqual(f1, flight.GetFlighstByOriginCountry(f1.OriginCountryCode)[0]); }
public void TestInitialize() { airlineDAO = new AirlineDAOMSSQL(); AirlineDAOMSSQL._connectionString = MyConfig._replicaConnectionString; ticketDAO = new TicketDAOMSSQL(); TicketDAOMSSQL._connectionString = MyConfig._replicaConnectionString; flightDAO = new FlightDAOMSSQL(); FlightDAOMSSQL._connectionString = MyConfig._replicaConnectionString; administratorDAO = new AdministratorDAOMSSQL(); AdministratorDAOMSSQL._connectionString = MyConfig._replicaConnectionString; customerDAO = new CustomerDAOMSSQL(); CustomerDAOMSSQL._connectionString = MyConfig._replicaConnectionString; countryDAO = new CountryDAOMSSQL(); CountryDAOMSSQL._connectionString = MyConfig._replicaConnectionString; airlineDAO.RemoveAllReplica(); ticketDAO.RemoveAllReplica(); countryDAO.RemoveAllReplica(); flightDAO.RemoveAllReplica(); customerDAO.RemoveAllReplica(); administratorDAO.RemoveAllReplica(); facade = new AnnonymousUserFacadeMSSQL(); }
public void GetAllFlightsNullDAOException() { flightDAO = null; Assert.AreEqual(2, facade.GetAllFlights().Count); }
public void AirlineComapnyFacadeTest() { string username = "******"; string password = "******"; FlightDAOMSSQL flight = new FlightDAOMSSQL(); CountryDAOMSSQL c = new CountryDAOMSSQL(); AirlineDAOMSSQL airline = new AirlineDAOMSSQL(); flight.RemoveAll(); airline.RemoveAll(); c.RemoveAll(); Country c1 = new Country("israel"); c.Add(c1); DateTime t = DateTime.Now; DateTime t1 = new DateTime(2019, 08, 29, 22, 33, 22); AirlineCompany company1 = new AirlineCompany("elal", "elel", "123", c1.Id); airline.Add(company1); Flight f1 = new Flight(company1.Id, c1.Id, c1.Id, t, t1, 22); flight.Add(f1); FlyingCenterSystem centerSystem = new FlyingCenterSystem(); LoggedInAirlinefacade airlinefacade; bool filled = false; centerSystem.OpenLogInSystem(username, password, out airlinefacade, ref filled); if (filled) { IList <AirlineCompany> airlineCompaniesList = airlinefacade.GetAllAirlineCompanies(); Assert.AreEqual(company1, airlineCompaniesList[0]); IList <Flight> flightsList = airlinefacade.GetAllFlights(); Assert.AreEqual(f1, flightsList[0]); Dictionary <Flight, int> reaminingTicketMapFlights = airlinefacade.GetAllFlightsVacancy(); Assert.AreEqual(f1.RemainingTickets, reaminingTicketMapFlights[f1]); IList <Ticket> ticketsOfAirlineCompanyList = airlinefacade.GetAllTickets(airlinefacade.AirlineToken); Flight flightById = airlinefacade.GetFlightById(f1.Id); Assert.AreEqual(f1, flightById); IList <Flight> fflightsByDeparyreTimeList = airlinefacade.GetFlightsByDepartureDate(f1.DepartureTime); Assert.AreEqual(f1, fflightsByDeparyreTimeList[0]); IList <Flight> flightsBydestinationCountryList = airlinefacade.GetFlightsByDestionationCountry(c1.Id); Assert.AreEqual(f1, flightsBydestinationCountryList[0]); IList <Flight> flightsByLandingTimeList = airlinefacade.GetFlightsByLandingeDate(f1.LandingTime); Assert.AreEqual(f1, flightsByLandingTimeList[0]); IList <Flight> flightsByOriginCountryList = airlinefacade.GetFlightsByOriginCountry(c1.Id); Assert.AreEqual(f1, flightsByOriginCountryList[0]); f1.RemainingTickets = f1.RemainingTickets - 3; airlinefacade.UpdateFlight(airlinefacade.AirlineToken, f1); Dictionary <Flight, int> updatedVanacyMapFligh = airlinefacade.GetAllFlightsVacancy(); Assert.AreEqual(f1.RemainingTickets, updatedVanacyMapFligh[f1]); //Assert.AreSame(f1, airlinefacade.GetFlightById(f1.Id)); ////airlinefacade.CancelFlight(airlinefacade.AirlineToken, f1); ////airlinefacade.ChangeMyPassword(airlinefacade.AirlineToken, "", ""); } else { Assert.AreEqual(2, 3); } }
public List <Flight> GetFlightsByOriginCountry(int countryCode) { _flightDAO = new FlightDAOMSSQL(); return(_flightDAO.GetFlightsByOriginCountry(countryCode)); }