public void GetAll()
        {
            countryDAO.Add(new Country("Israel"));

            airlineDAO.Add(new AirlineCompany("ELAL", "ELAL123", "ELALPASSWORD", countryDAO.GetCountryByName("Israel").ID));
            airlineDAO.Add(new AirlineCompany("ARKIA", "ARKIA123", "ARKIAPASSWORD", countryDAO.GetCountryByName("Israel").ID));

            List <AirlineCompany> airlinesList = airlineDAO.GetAll();

            Assert.AreEqual(2, airlinesList.Count);
            Assert.AreEqual("ELAL", airlinesList[0].AirLineName);
            Assert.AreEqual("ARKIA", airlinesList[1].AirLineName);
        }
Exemple #2
0
        public void CreateNewAirline_Test()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadeBase, out ILoginToken loginToken, "amir54", "fsdf3");
            LoginToken <Administrator>  token  = (LoginToken <Administrator>)loginToken;
            LoggedInAdministratorFacade facade = (LoggedInAdministratorFacade)facadeBase;
            User user = new User()
            {
                User_Name = "Wings",
                Password  = "******",
                Email     = "*****@*****.**",
                User_Role = 2
            };
            AirlineCompany airlineCompany = new AirlineCompany
            {
                Name       = "flying wings",
                Country_Id = 2,
                User       = user
            };

            facade.CreateNewAirline(token, airlineCompany);
            Assert.AreEqual(_airlineDAO.GetAll().Count, 3);
        }
        public bool TryAirlineLogin(string userName, string password, out LoginToken <AirlineCompany> token)
        {
            var airline = _airlineDAO.GetAll().SingleOrDefault(a => a.UserName == userName);

            if (airline != null)
            {
                if (airline.Password == password)
                {
                    token = new LoginToken <AirlineCompany> {
                        User = airline
                    };
                    return(true);
                }
                else
                {
                    throw new WrongPasswordException();
                }
            }
            throw new UserNotFoundException($"userName: {userName} of type airlinecompany could not be found");
        }
 public IList <AirlineCompany> GetAllAirlineCompanies()
 {
     return(_airlineDAO.GetAll());
 }
        public void Add()
        {
            Customer theCustomer = new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PHNUMBER", "CRDNUMBER");

            customerDAO.Add(theCustomer);
            theCustomer = customerDAO.GetAll()[0];

            Country israel = new Country("Israel");

            countryDAO.Add(israel);
            israel = countryDAO.GetAll()[0];

            AirlineCompany elal = new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSWORD", israel.ID);

            airlineDAO.Add(elal);
            elal = airlineDAO.GetAll()[0];

            Flight theFlight = new Flight(elal.ID, israel.ID, israel.ID, new DateTime((DateTime.Now.Year + 2), 12, 5, 14, 00, 00), new DateTime((DateTime.Now.Year + 2), 12, 7, 14, 00, 00), 50, FlightStatus.NotDeparted);

            flightDAO.Add(theFlight);
            theFlight = flightDAO.GetAll()[0];

            ticketDAO.Add(new Ticket(theFlight.ID, theCustomer.ID));
            Assert.AreEqual(1, ticketDAO.GetAll().Count);
        }