public void Create_New_Administrator_Using_Level_One_Admin()
 {
     Init_Admin_Level_One_And_Login();
     Execute_Test(() =>
     {
         Administrator demi_administrator = TestData.Get_Administrators_Data()[1];
         Assert.ThrowsException <NotAllowedAdminActionException>(() => administrator_level_one_facade.CreateNewAdmin(administrator_level_one_token, demi_administrator));
     });
 }
        public void UserNameAlreadyExists()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
        }
        public void CancelFlight()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID);
            UserRepository airlineTestUr  = new UserRepository("rad", "ass", RolesEnum.airline);

            myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country);
            Flight flight = new Flight(DateTime.Now, DateTime.Now, 50, airlineCompany.ID, country.ID, country.ID);

            FlyingCenterSystem.GetInstance().TryLogin(airlineTestUr.UserName, airlineTestUr.Password, out ILogin tokenAir,
                                                      out FacadeBase facadeAir);
            LoginToken <AirlineCompany> myTokenair  = tokenAir as LoginToken <AirlineCompany>;
            LoggedInAirlineFacade       myFacadeAir = facadeAir as LoggedInAirlineFacade;

            myFacadeAir.CreateFlight(myTokenair, flight);
            myFacadeAir.CancelFlight(myTokenair, flight);
            Flight flight1 = myFacadeAir.GetFlightById(flight.ID);

            Assert.IsNull(flight1);
        }
        public void ChangeMyPassword()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID);
            UserRepository airlineTestUr  = new UserRepository("rad", "ass", RolesEnum.airline);

            myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country);
            Flight flight = new Flight(DateTime.Now, DateTime.Now, 50, airlineCompany.ID, country.ID, country.ID);

            FlyingCenterSystem.GetInstance().TryLogin(airlineTestUr.UserName, airlineTestUr.Password, out ILogin tokenAir,
                                                      out FacadeBase facadeAir);
            LoginToken <AirlineCompany> myTokenair  = tokenAir as LoginToken <AirlineCompany>;
            LoggedInAirlineFacade       myFacadeAir = facadeAir as LoggedInAirlineFacade;
            string pass = airlineTestUr.Password;

            myFacadeAir.ChangeMyPassword(myTokenair, "asd");
            airlineTestUr = myFacade.GetUserRepositoryDetails(myToken, airlineTestUr);
            Assert.AreNotEqual(airlineTestUr.Password, pass);
        }
Example #5
0
        public void GetAllFlightsThatIsentFullyBooked()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID);
            UserRepository airlineTestUr  = new UserRepository("rad", "ass", RolesEnum.airline);

            myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country);
            Flight flight = new Flight(DateTime.Now, DateTime.Now, 50, airlineCompany.ID, country.ID, country.ID);

            FlyingCenterSystem.GetInstance().TryLogin(airlineTestUr.UserName, airlineTestUr.Password, out ILogin tokenAir,
                                                      out FacadeBase facadeAir);
            LoginToken <AirlineCompany> myTokenair  = tokenAir as LoginToken <AirlineCompany>;
            LoggedInAirlineFacade       myFacadeAir = facadeAir as LoggedInAirlineFacade;

            myFacadeAir.CreateFlight(myTokenair, flight);
            AnonymousUserFacade      anonymousUserFacade = new AnonymousUserFacade();
            Dictionary <Flight, int> flights             = (Dictionary <Flight, int>)anonymousUserFacade.GetAllFlightsVacancy();

            Assert.IsNotNull(flights);
        }
Example #6
0
        // 1. Read Random Admin From API Web.
        public void ReadAdminsFromAPI(int times)
        {
            MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger.Add("Start Create Adminsitrators..."))));
            int success = 0;

            for (int i = 0; i < times; i++)
            {
                HttpResponseMessage response = client.GetAsync("").Result;
                if (response.IsSuccessStatusCode)
                {
                    APIUser adminAPI = response.Content.ReadAsAsync <APIUser>().Result;
                    adminFacade.CreateNewAdmin(adminToken, new Administrator(adminAPI.results[0].login.username, adminAPI.results[0].login.password));
                    MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger[ViewModel.Logger.Count - 1] = $"- {i + 1}/{times} Administrators Was Generated.")));
                    success++;
                }
                ViewModel.HowMuchCreated++;
            }
            if (times > 0)
            {
                log.Info($"\n{success} Administrators Were Created And {times - success} Failed.\n");
                MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger.Add($"- Administrators Generator Is Over. ({success} Were Created And {times - success} Failed)."))));
            }
            else
            {
                MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger[ViewModel.Logger.Count - 1] = $"- No Creation Request For Administrators.")));
            }
        }
Example #7
0
        public void WrongPasswordWhenTryLoginAsAdmin()
        {
            FlyingCenterSystem.TryLogin(FlyingCenterConfig.ADMIN_NAME, FlyingCenterConfig.ADMIN_PASSWORD, out ILogin token, out FacadeBase user);
            LoginToken <Administrator>  Mytoken = token as LoginToken <Administrator>;
            LoggedInAdministratorFacade MyUser  = user as LoggedInAdministratorFacade;

            MyUser.CreateNewAdmin(Mytoken, new Administrator {
                User_Name = CreateUserName(), Password = "******"
            });
            FlyingCenterSystem.TryLogin("SecondAdmin", "123", out ILogin token2, out FacadeBase user2);
        }
        public void RemoveAdminAndHisUserRepository()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            myFacade.RemoveAdmin(myToken, testAdmin.UserRepositoryID.ToString());
            Admin admin2 = myFacade.GetAdminByid(myToken, testAdmin.ID.ToString());
        }
        public void UpdateAdmin()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Admin admin2 = myFacade.GetAdminByid(myToken, testAdmin.ID.ToString());

            testAdmin.FirstName = "tts";
            myFacade.UpdateAdminDetails(myToken, testAdmin);
            Assert.AreNotEqual(admin2.FirstName, testAdmin.FirstName);
        }
        public void AddAnewCountryAndGetIt()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            Country testCounty = myFacade.GetCountryByID(myToken, country.ID.ToString());

            Assert.AreEqual(country.ID, testCounty.ID);
        }
        public void GetAllMyFlights()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID);
            UserRepository airlineTestUr  = new UserRepository("rad", "ass", RolesEnum.airline);

            myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country);
            Flight flight = new Flight(DateTime.Now, DateTime.Now, 50, airlineCompany.ID, country.ID, country.ID);

            FlyingCenterSystem.GetInstance().TryLogin(airlineTestUr.UserName, airlineTestUr.Password, out ILogin tokenAir,
                                                      out FacadeBase facadeAir);
            LoginToken <AirlineCompany> myTokenair  = tokenAir as LoginToken <AirlineCompany>;
            LoggedInAirlineFacade       myFacadeAir = facadeAir as LoggedInAirlineFacade;

            myFacadeAir.CreateFlight(myTokenair, flight);
            AnonymousUserFacade anonymousUserFacade    = new AnonymousUserFacade();
            Customer            customer               = new Customer("asdjkb", "fgh", "adthv", "0506794532", "123479520589243", 2);
            UserRepository      customerUserRepository = new UserRepository("radp", "ass", RolesEnum.customer);

            anonymousUserFacade.CreateCustomerAndUserRepository(customerUserRepository, customer);
            FlyingCenterSystem.GetInstance().TryLogin(customerUserRepository.UserName, customerUserRepository.Password, out ILogin tokenCustomer,
                                                      out FacadeBase facadeCustomer);
            LoginToken <Customer>  myTokencustomer        = tokenCustomer as LoginToken <Customer>;
            LoggedInCustomerFacade loggedInCustomerFacade = facadeCustomer as LoggedInCustomerFacade;

            loggedInCustomerFacade.PurchaseTicket(myTokencustomer, flight);
            List <Flight> flights = (List <Flight>)loggedInCustomerFacade.GetAllMyFlights(myTokencustomer);

            Assert.IsNotNull(flights);
        }
        public void RemoveCustomerAndHisUserRepository()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            UserRepository customerTestUr = new UserRepository("David", "Noho", RolesEnum.customer);
            Customer       customer       = new Customer("David", "Noho", "Tel", "0506794632", "78458956852174587", 2);

            myFacade.CreateCustomerAndUserRepository(customerTestUr, customer);
            myFacade.RemoveCustomer(myToken, customer.User_Repository_ID.ToString());
            myFacade.GetCustomerByid(myToken, customer.ID.ToString());
        }
        public void AddAirlineCompanyAndGetIt()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID);
            UserRepository airlineTestUr  = new UserRepository("rad", "ass", RolesEnum.airline);

            myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country);
            AirlineCompany airlineCompany1 = myFacade.GetAirlineCompanyByid(myToken, airlineCompany.ID.ToString());

            Assert.AreEqual(airlineCompany.ID, airlineCompany1.ID);
        }
        public void GetAllAirlineCompaniesOfACountry()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID);
            UserRepository airlineTestUr  = new UserRepository("rad", "ass", RolesEnum.airline);

            myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country);
            List <AirlineCompany> airlineCompanies = (List <AirlineCompany>)myFacade.GetAllAirlineCompaniesOfACountry(myToken, country.ID);

            Assert.IsNotNull(airlineCompanies);
        }
Example #15
0
        public void CreateACustomerAndAUserRepositoryForThatCustomer()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AnonymousUserFacade anonymousUserFacade    = new AnonymousUserFacade();
            Customer            customer               = new Customer("asd", "fgh", "adthv", "0506794532", "123479520589243", 2);
            UserRepository      customerUserRepository = new UserRepository("rad", "ass", RolesEnum.customer);

            anonymousUserFacade.CreateCustomerAndUserRepository(customerUserRepository, customer);
            Customer customer1 = myFacade.GetCustomerByid(myToken, customer.ID.ToString());

            Assert.AreEqual(customer.ID, customer1.ID);
        }
        private void Init_Admin_Level_One_And_Login()
        {
            _logger.Debug($"Start Init Admin Level One Tests Data");

            Administrator admin_level_one    = TestData.Get_Administrators_Data()[0];
            int           admin_level_one_id = administrator_facade.CreateNewAdmin(administrator_token, admin_level_one);

            system.TryLogin(admin_level_one.User.UserName, admin_level_one.User.Password, out ILoginToken token, out FacadeBase facade);
            administrator_level_one_token  = token as LoginToken <Administrator>;
            administrator_level_one_facade = facade as LoggedInAdministratorFacade;

            _logger.Debug($"End Init Admin Level One Tests Data");
        }
Example #17
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            // Creating new customer.
            Customer newCustomer = new Customer
            {
                FIRST_NAME         = "Iliya",
                LAST_NAME          = "Tsvibel",
                USER_NAME          = "Iliya",
                PASSWORD           = "******",
                ADDRESS            = "Rishon",
                PHONE_NO           = "0546800559",
                CREDIT_CARD_NUMBER = "12345"
            };

            adminFacade.CreateNewCustomer(defaultToken, newCustomer);

            // Creating new country.
            Country country = null;

            country = new Country();
            for (int i = 0; i < ListOfCountries.CountryNames.Length; i++)
            {
                country = countryDAO.GetByName(ListOfCountries.CountryNames[i]);

                if (country == null)
                {
                    Country newCountry = new Country {
                        COUNTRY_NAME = ListOfCountries.CountryNames[i]
                    };
                    adminFacade.CreateNewCountry(defaultToken, newCountry);
                }
            }

            // Creating new administrator.
            Administrator newAdmin = new Administrator {
                FIRST_NAME = "Iliya", LAST_NAME = "Tsvibel", USER_NAME = "Admin", PASSWORD = "******"
            };

            adminFacade.CreateNewAdmin(defaultToken, newAdmin);

            //Creating new airline.
            //AirlineCompany newAirline = new AirlineCompany
            //{
            //    AIRLINE_NAME = "Aeroflot",
            //    USER_NAME = "Vladimir",
            //    COUNTRY_CODE = adminFacade.GetCountryByName("Germany").ID,
            //    PASSWORD = "******"
            //};
            //adminFacade.CreateNewAirline(defaultToken, newAirline);

            AirlineCompany airline = null;

            airline = new AirlineCompany();
            long countryStartID = 0;

            countryStartID = countryDAO.GetByName(ListOfCountries.CountryNames[0]).ID;
            for (int i = 0; i < ListOfAirlinesCompanies.AirlineNames.Length; i++)
            {
                airline = airlineDAO.GetAirlineByName(ListOfAirlinesCompanies.AirlineNames[i]);

                if (airline == null)
                {
                    AirlineCompany newAirline = new AirlineCompany {
                        AIRLINE_NAME = ListOfAirlinesCompanies.AirlineNames[i], USER_NAME = "UserName-" + ListOfAirlinesCompanies.AirlineNames[i], PASSWORD = random.Next(1000, 10000).ToString(), COUNTRY_CODE = random.Next(Convert.ToInt32(countryStartID), (Convert.ToInt32(countryStartID) + ListOfCountries.CountryNames.Length))
                    };
                    adminFacade.CreateNewAirline(defaultToken, newAirline);
                }
            }

            // Creating new flight.
            Flight flight = new Flight {
                AIRLINECOMPANY_ID = adminFacade.GetAirlineByName(adminToken, "SOLAR CARGO, C.A.").ID, DEPARTURE_TIME = DateTime.Now, LANDING_TIME = DateTime.Now + TimeSpan.FromHours(1), ORIGIN_COUNTRY_CODE = adminFacade.GetCountryByName("Germany").ID, DESTINATION_COUNTRY_CODE = adminFacade.GetCountryByName("Germany").ID, REMAINING_TICKETS = 250
            };

            //airlineFacade.CreateFlight(defaultAirlioneToken, flight);
            flightDAO.Add(flight);

            // Creating new ticket.
            Ticket tickets = new Ticket {
                FLIGHT_ID = anonFacade.GetFlightsByDestinationCountryForTest(adminFacade.GetCountryByName("Germany").ID).ID, CUSTOMER_ID = adminFacade.GetCustomerByUserName(adminToken, "Iliya").ID
            };

            //customerFacade.PurchaseTicket(defaultCustomerToken, tickets);
            ticketDAO.Add(tickets);
            MessageBox.Show($"All data successfully added");
        }