public void CreateNewCustomerTest() { CustomerDAOMSSQL c = new CustomerDAOMSSQL(); Assert.AreEqual(c.GetAll().Count, 1); Customer customer = new Customer("Israel", "Mori", "Israel12", "Israel123", "Yehud", "0545292907", "123456787"); TestCenter.AdminFacade.CreateNewCustomer(TestCenter.AdminToken, customer); Assert.AreEqual(c.GetAll().Count, 2); }
public void CreateNewCustomerTest() { t.ClearDataBase(); CustomerDAOMSSQL DAO = new CustomerDAOMSSQL(); Assert.IsNull(DAO.GetAll()); Customer cust = new Customer("ronni", "nissimov", "ronnissimov", "123456", "parde-hannah", "054-7908050", "1234-5678-9876-5432"); t.adminFacade.CreateNewCustomer(t.adminToken, cust); Assert.AreEqual(DAO.GetAll().Count, 1); }
public void RemoveCustomerTest() { t.ClearDataBase(); CustomerDAOMSSQL DAO = new CustomerDAOMSSQL(); Assert.IsNull(DAO.GetAll()); Customer cust = t.CreateCustomerForTests(); Assert.AreEqual(DAO.GetAll().Count, 1); t.adminFacade.RemoveCustomer(t.adminToken, cust); Assert.IsNull(DAO.GetAll()); }
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)); }
private void ShowAll() { string str = string.Empty; foreach (var s in _currentCustomersDAO.GetAll()) { str += JsonConvert.SerializeObject(s) + Environment.NewLine; } MessageBox.Show(str); }
public void GetAllMyTickets() { countryDAO.Add(new Country("Israel")); airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", countryDAO.GetCountryByName("Israel").ID)); airlineDAO.Add(new AirlineCompany("ARKIA", "ARKIAUSERNAME", "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)); 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.GetAll()[0].ID)); ticketDAO.Add(new Ticket(flightDAO.GetAll()[1].ID, customerDAO.GetAll()[0].ID)); ticketDAO.Add(new Ticket(flightDAO.GetAll()[2].ID, customerDAO.GetAll()[0].ID)); LoginToken <AirlineCompany> airlineLoggenIn = new LoginToken <AirlineCompany>(); airlineLoggenIn.user = airlineDAO.GetAirlineByName("ARKIA"); Assert.AreEqual(2, facade.GetAllMyTickets(airlineLoggenIn).Count); }
/// <summary> /// method that selects the appropriate method for adding a a database member depending on the this class Generic parameter ("T") /// </summary> private void Initialize() { _countries = _countryDAO.GetAll(); _airlineCompanies = _airlineCompanyDAO.GetAll(); _flights = _flightDAO.GetAll(); _customers = _customerDAO.GetAll(); _utility_user_types.Add(typeof(Administrator)); _utility_user_types.Add(typeof(Customer)); _utility_user_types.Add(typeof(AirlineCompany)); _genericTypeMethodCorrelation.Add(typeof(Customer), AddCustomers); _genericTypeMethodCorrelation.Add(typeof(Administrator), AddAdministrators); _genericTypeMethodCorrelation.Add(typeof(Flight), AddFlights); _genericTypeMethodCorrelation.Add(typeof(Country), this.AddCountries); _genericTypeMethodCorrelation.Add(typeof(AirlineCompany), this.AddAirlineCompanies); _genericTypeMethodCorrelation.Add(typeof(Ticket), this.AddTickets); //add more "Add["type_name"]" functions to the dictionary when they created }
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() { facade.CreateNewCustomer(new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PHONENUMBER", "CARDNUMBER")); Assert.AreEqual(1, customerDAO.GetAll().Count); Assert.AreEqual("FIRSTNAME", customerDAO.GetAll()[0].FirstName); }
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); }