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 RemoveCustomerTest() { CustomerDAOMSSQL c = new CustomerDAOMSSQL(); Assert.IsNotNull(c.Get(TestCenter.CustomerToken.User.Id)); TestCenter.AdminFacade.RemoveCustomer(TestCenter.AdminToken, TestCenter.CustomerToken.User); Assert.IsNull(c.Get(TestCenter.CustomerToken.User.Id)); }
public FacadeBase() { _airlineDAO = new AirlineDAOMSSQL(); _countryDAO = new CountryDAOMSSQL(); _customerDAO = new CustomerDAOMSSQL(); _flightDAO = new FlightDAOMSSQL(); _ticketDAO = new TicketDAOMSSQL(); }
public void CreateNewCustomer(LoginToken <Administrator> token, Customer customer) { if (token != null) { _customerDAO = new CustomerDAOMSSQL(); _customerDAO.Add(customer); } }
public void RemoveCustomer(LoginToken <Administrator> token, Customer customer) { if (token != null) { _customerDAO = new CustomerDAOMSSQL(); _customerDAO.Remove(customer); } }
public void UpdateCustomerDetails(LoginToken <Administrator> token, Customer customer) { if (token != null) { _customerDAO = new CustomerDAOMSSQL(); _customerDAO.Update(customer); } }
public void DeleteMyAccountTest() { CustomerDAOMSSQL c = new CustomerDAOMSSQL(); Assert.IsNotNull(c.Get(TestCenter.CustomerToken.User.Id)); TestCenter.CustomerFacade.DeleteMyAccount(TestCenter.CustomerToken, TestCenter.CustomerToken.User); Assert.IsNull(c.Get(TestCenter.CustomerToken.User.Id)); }
public void TestWrongPasswordException() { test = new TestInfo(); CustomerDAOMSSQL cDAO = new CustomerDAOMSSQL(); Customer c = new Customer("jon", "dow", "james", "4567", "alkana", "054555440", "321456"); long id = test.adminF.CreateNewCustomer(test.adminT, c); test.FC.Login(c.UserName, "123"); }
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 TestRemoveCustomer() { test = new TestInfo(); Customer testCustomer = new Customer("dan", "horesh", "dan", "2345", "alkana", "054555440", "321456"); testCustomer.ID = test.adminF.CreateNewCustomer(test.adminT, testCustomer); CustomerDAOMSSQL cusDAO = new CustomerDAOMSSQL(); Assert.AreEqual(testCustomer.ID, cusDAO.Get(testCustomer.ID).ID); }
public void UpdateCustomerTest() { CustomerDAOMSSQL c = new CustomerDAOMSSQL(); Assert.AreEqual(TestCenter.CustomerToken.User, c.GetCustomerByUserName(TestCenter.CustomerToken.User.UserName)); TestCenter.CustomerToken.User.UserName = "******"; Assert.AreNotEqual(TestCenter.CustomerToken.User, c.GetCustomerByUserName(TestCenter.CustomerToken.User.UserName)); TestCenter.AdminFacade.UpdateCustomerDetails(TestCenter.AdminToken, TestCenter.CustomerToken.User); Assert.AreEqual(TestCenter.CustomerToken.User, c.GetCustomerByUserName(TestCenter.CustomerToken.User.UserName)); }
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 TestUpdateCustomer() { test = new TestInfo(); Customer customer = new Customer("rami", "lavy", "rami", "1234", "alkana", "054555440", "321456"); customer.ID = test.adminF.CreateNewCustomer(test.adminT, customer); CustomerDAOMSSQL customerDAO = new CustomerDAOMSSQL(); customer.FirstName = "levi"; Assert.AreNotEqual(customer.FirstName, customerDAO.Get(customer.ID).FirstName); test.adminF.UpdateCustomerDetails(test.adminT, customer); Assert.AreEqual(customer.FirstName, customerDAO.Get(customer.ID).FirstName); }
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 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 bool TryCustomerLogin(string password, string userName, out LoginToken <Customer> loginToken) { bool res = false; loginToken = null; _customerDAO = new CustomerDAOMSSQL(); Customer cust = _customerDAO.GetCustomerByUserName(userName); if (!(cust is null)) { if (cust.password != password) { throw new WrongPasswordException("entered password is not correct"); } else { res = true; loginToken = new LoginToken <Customer>(); loginToken.User = cust; } } return(res); }
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 Customer GetCustomerByUserName(string userName) { _customerDAO = new CustomerDAOMSSQL(); return(_customerDAO.GetCustomerByUserame(userName)); }
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 bool TryCustomerLogin(string userName, string password, out LoginToken <Customer> token) { Customer name = _customerADO.GetCustomerByUserame(userName); //AirlineCompany company = _arilineDAO.GetAirlineByUserame(userName); //if (company != null) //{ // if (company.PASSWORD == password) // { // token = new LoginToken<AirlineCompany>() { User = company }; // return true; // } while (name == null) //AirlineID? { try { CustomerDAOMSSQL.CustomerLogin(name); token = new LoginToken <Customer>() { User = name }; Console.WriteLine("User was logged successfully"); return(true); //ExistingAirflineUserMenu(company); } catch (CustomerDoesNotExistException) { Console.WriteLine("This airline company does not exist."); Console.WriteLine("Input correct username or type e to exit."); userName = Console.ReadLine(); Console.WriteLine(); if (userName == "e") { break; } else { name.USER_NAME = userName; continue; } } catch (WrongPasswordException) { Console.WriteLine("Incorrect password."); Console.WriteLine("Input correct password or type e to exit."); password = Console.ReadLine(); Console.WriteLine(); if (password == "e") { break; } else { name.PASSWORD = password; continue; } } } token = null; return(false); }
public List <long> GetAllCustomerID() { _customerDAO = new CustomerDAOMSSQL(); return(_customerDAO.GetAllCustomerID()); }
public LoginService() { _airlineDAO = new AirlineDAOMSSQL(); _customerDAO = new CustomerDAOMSSQL(); }
public Customer CheckCustLogin(Customer customer) { _customerDAO = new CustomerDAOMSSQL(); return(_customerDAO.GetCustomerByUserame(customer.USER_NAME)); }
public void CreateNewCustomer(Customer customer) { _customerDAO = new CustomerDAOMSSQL(); _customerDAO.Add(customer); }