예제 #1
0
        public void CancelFlight()
        {
            countryDAO.Add(new Country("Israel"));

            airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", countryDAO.GetCountryByName("Israel").ID));
            airlineDAO.Add(new AirlineCompany("ARKIA", "ARKIAYSERNAME", "ARKIAPASSWORD", countryDAO.GetCountryByName("Israel").ID));

            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ELAL").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));
            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ARKIA").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));

            customerDAO.Add(new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PNUMBER", "CNUMBER"));

            ticketDAO.Add(new Ticket(flightDAO.GetAll()[0].ID, customerDAO.GetCustomerByUsername("USERNAME").ID));
            ticketDAO.Add(new Ticket(flightDAO.GetAll()[1].ID, customerDAO.GetCustomerByUsername("USERNAME").ID));

            Assert.AreEqual(2, flightDAO.GetAll().Count);
            Assert.AreEqual(2, ticketDAO.GetAll().Count);

            LoginToken <AirlineCompany> airlineLoggenIn = new LoginToken <AirlineCompany>();

            airlineLoggenIn.user = airlineDAO.GetAirlineByName("ELAL");
            facade.CancelFlight(airlineLoggenIn, flightDAO.GetAll()[0]);
            Assert.AreEqual(1, flightDAO.GetAll().Count);
            Assert.AreEqual(1, ticketDAO.GetAll().Count);
        }
예제 #2
0
        public void RemoveCustomer()
        {
            Customer customerTest = new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PHONENUMBER", "CARDNUMBER");

            customerDAO.Add(customerTest);
            customerTest = customerDAO.GetCustomerByUsername("USERNAME");

            facade.RemoveCustomer(customerTest);
            Assert.AreEqual(null, customerDAO.GetAll());
        }
예제 #3
0
        public bool TryCustomerLogin(string userName, string password, out LoginToken <Customer> token)
        {
            Customer customer = customerDAOMSSQL.GetCustomerByUsername(userName);

            if (customer == null)
            {
                token = null;
                return(false);
            }
            else if (customer.Password != password)
            {
                throw new WrongPasswordException();
            }
            else
            {
                token      = new LoginToken <Customer>();
                token.User = customer;
                return(true);
            }
        }