예제 #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 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));
        }
예제 #3
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());
        }
예제 #4
0
 public void CreateNewCustomer(LoginToken <Administrator> token, Customer customer)
 {
     if (token != null)
     {
         _customerDAO = new CustomerDAOMSSQL();
         _customerDAO.Add(customer);
     }
 }
        public void LoginCustomer()
        {
            Customer customerUser = customerDAO.Add(new Customer("FIRST", "LAST", "USERNAME", "PASSWORD", "ADDRESS", "PNUMBER", "CNUMBER"));

            FacadeBase  facade;
            ILoginToken loginToken;

            centerSystem.Login("USERNAME", "PASSWORD", out facade, out loginToken);

            Assert.IsTrue(loginToken is LoginToken <Customer>);
            Assert.IsTrue(facade is LoggedInCustomerFacadeMSSQL);
        }
        internal void AddCustomerToDB(int number)
        {
            int counter = 0;

            try
            {
                List <Customer>     customerFromDB = _customerDAO.GetAll().ToList();
                HttpResponseMessage httpResponse   = client.GetAsync(url + "?results=" + number).Result;
                for (int i = 0; i < number; i++)
                {
                    // HttpResponseMessage httpResponse = client.GetAsync(url + "?results=" + number).Result;
                    if (httpResponse.IsSuccessStatusCode)
                    {
                        Customer c       = new Customer();
                        var      content = httpResponse.Content.ReadAsStringAsync().Result;
                        APIUser  r       = JsonConvert.DeserializeObject <APIUser>(content);
                        if (!customerFromDB.Any(customer => customer.UserName == r.results[i].login.username))
                        {
                            c.FirstName = r.results[i].name.first;
                        }
                        c.LastName         = r.results[i].name.last;
                        c.Password         = r.results[i].login.password;
                        c.UserName         = r.results[i].login.username;
                        c.PhoneNo          = r.results[i].phone;
                        c.Address          = r.results[i].location.city;
                        c.CreditCardNumber = r.results[i].cell;
                        _customerDAO.Add(c);
                        _customers.Add(c);
                        counter++;

                        ProgressValue += Convert.ToInt32(1.0 / Total * 100);
                    }
                }
                Message += $"Created Customers {counter}/{number}\n";
            }
            catch (Exception e)
            {
                Message += $"{e.ToString()}\n";
            }
        }
 public void CreateNewCustomer(Customer customer)
 {
     _customerDAO = new CustomerDAOMSSQL();
     _customerDAO.Add(customer);
 }
예제 #8
0
        public void AdminFacadeTest()
        {
            // Deleting database
            FlightCenterConfig.DeleteDataBase();
            //Creating DAO'S samples to test
            long             airlineCompanyId1 = 0, airlineCompanyId2 = 0, countryId1 = 0, countryId2 = 0, flightId1 = 0, customerId1 = 0;
            AirLineDAOMSSQL  adao = new AirLineDAOMSSQL();
            FlightDAOMSSQL   fdao = new FlightDAOMSSQL();
            CustomerDAOMSSQL cdao = new CustomerDAOMSSQL();
            CountryDAOMSSQL  cydao = new CountryDAOMSSQL();
            TicketDAOMSSQL   tdao = new TicketDAOMSSQL();

            // Adding new countries
            cydao.Add(new Country {
                COUNTRY_NAME = "Israel"
            });
            countryId1 = cydao.GetCountryId("Israel");

            cydao.Add(new Country {
                COUNTRY_NAME = "Germany"
            });
            countryId2 = cydao.GetCountryId("Germany");

            // Adding new Airline companies
            adao.Add(new AirlineCompany {
                AIRLINE_NAME = "IsrLines", USER_NAME = "ISR91", PASSWORD = "******", COUNTRY_CODE = countryId1
            });
            airlineCompanyId1 = adao.GetAirlineCompanyId("ISR91");

            adao.Add(new AirlineCompany {
                AIRLINE_NAME = "British Airlines", USER_NAME = "British555", PASSWORD = "******", COUNTRY_CODE = countryId2
            });
            airlineCompanyId2 = adao.GetAirlineCompanyId("British555");

            // Adding new Flight
            fdao.Add(new Flight {
                AIRLINECOMPANY_ID = airlineCompanyId1, ORIGIN_COUNTRY_CODE = countryId1, DESTINATION_COUNTRY_CODE = countryId2, DEPARTURE_TIME = new DateTime(2019, 05, 10, 10, 30, 00), LANDING_TIME = new DateTime(2019, 05, 10, 15, 05, 00), REMAINING_TICKETS = 15, AIRLINECOMPANY_NAME = "IsrLines", FLIGHT_NAME = "555"
            });
            flightId1 = fdao.GetFlightId("555");

            // Adding new Customer
            cdao.Add(new Customer {
                FIRST_NAME = "Efrat", LAST_NAME = "Patihi", USER_NAME = "Efrat_kapara", PASSWORD = "******", ADDRESS = "Netanya , Raziel 40", PHONE_NO = "05011554875", CREDIT_CARD_NUMBER = "123456789"
            });
            customerId1 = cdao.GetCustomerId("Efrat_kapara");

            // Adding new Ticket
            tdao.Add(new Tickets {
                CUSTOMER_ID = customerId1, FLIGHT_ID = flightId1
            });
            // Testing
            FlyingCenterSystem         fcs        = FlyingCenterSystem.GetInstance();
            LoginToken <Administrator> adminLogin = new LoginToken <Administrator>();

            adminLogin.User = new Administrator();
            adminLogin.User.AdminUserName = "******";
            adminLogin.User.Password      = "******";


            // Trying to login
            fcs.login.TryAdminLogin(adminLogin.User.AdminUserName, adminLogin.User.Password, out LoginToken <Administrator> adminToken);
            fcs.login.TryAirlineLogin("ISR91", "Is789", out LoginToken <AirlineCompany> airlineToken);
            fcs.login.TryCustomerLogin("Efrat_kapara", "Efi93", out LoginToken <Customer> customerToken);


            // Testing admin facade fucntions
            LoggedInAdministratorFacade adminFacadae = fcs.GetFacade(adminLogin) as LoggedInAdministratorFacade;

            adminFacadae.CreateNewCountry(adminLogin, new Country {
                COUNTRY_NAME = "Israel"
            });
            AirlineCompany airline = new AirlineCompany()
            {
                AIRLINE_NAME = "Nassa",
                USER_NAME    = "Nassa28",
                PASSWORD     = "******",
                COUNTRY_CODE = adminFacadae.GetCountryId("Israel")
            };

            adminFacadae.CreateNewAirline(adminLogin, airline);
            Assert.AreEqual(adminFacadae.GetAirlineByUserame("Nassa28"), airline);

            Customer cust = new Customer()
            {
                FIRST_NAME         = "Tal",
                LAST_NAME          = "Rdt",
                USER_NAME          = "TalGever",
                PASSWORD           = "******",
                ADDRESS            = "Hazfira 20, Pardes hanna",
                PHONE_NO           = "0505001245",
                CREDIT_CARD_NUMBER = "456123456789"
            };

            adminFacadae.CreateNewCustomer(adminLogin, cust);
            Assert.AreEqual(cust, adminFacadae.GetCustomerByUserName("TalGever")); // works
            adminFacadae.UpdateAirlineDetails(adminLogin, new AirlineCompany {
                AIRLINE_NAME = "Nasa4Life", USER_NAME = "Nassa28", PASSWORD = "******", COUNTRY_CODE = adminFacadae.GetCountryId("Israel")
            });
            adminFacadae.UpdateCustomerDetails(adminLogin, new Customer {
                FIRST_NAME = "Tal", LAST_NAME = "Rdt", USER_NAME = "TalGever", PASSWORD = "******", ADDRESS = "Raziel 50 , Netanya", PHONE_NO = "0505001245", CREDIT_CARD_NUMBER = "456123456789"
            });
            AirlineCompany airl = new AirlineCompany()
            {
                AIRLINE_NAME = "Nasa4Life",
                USER_NAME    = "Nassa28",
                PASSWORD     = "******",
                COUNTRY_CODE = adminFacadae.GetCountryId("Israel")
            };

            adminFacadae.RemoveAirline(adminLogin, airl);
        }
        public void CancelTicket()
        {
            countryDAO.Add(new Country("Israel"));

            airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", 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));
            Flight flightOne = flightDAO.GetAll()[0];

            customerDAO.Add(new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PNUMBER", "CNUMBER"));
            customerDAO.Add(new Customer("FIRSTNAME2", "LASTNAME2", "USERNAME2", "PASSWORD2", "ADDRESS2", "PNUMBER2", "CNUMBER2"));
            Customer customerOne = customerDAO.GetAll()[0];
            Customer customerTwo = customerDAO.GetAll()[1];

            LoginToken <Customer> customerLoggedIn = new LoginToken <Customer>();

            customerLoggedIn.user = customerOne;

            ticketDAO.Add(new Ticket(flightOne.ID, customerOne.ID));
            ticketDAO.Add(new Ticket(flightOne.ID, customerTwo.ID));
            Ticket ticketOne = ticketDAO.GetAll()[0];

            flightOne = flightDAO.GetAll()[0];

            Assert.AreEqual(28, flightOne.RemainingTickets);
            facade.CancelTicket(customerLoggedIn, ticketOne);
            flightOne = flightDAO.GetAll()[0];
            Assert.AreEqual(29, flightOne.RemainingTickets);
            Assert.AreEqual(1, ticketDAO.GetAll().Count);
        }