public void TestForCompaniesController() { LoggedInAdministratorFacade adminFacade = new LoggedInAdministratorFacade(); AirlineCompany company = CreateRandomCompany(); adminFacade.CreateNewAirline(FlyingCenterConfig.basicToken, company); string companyToken = GetTokenAsync(new User(company.User_Name, company.Password, UserType.Airline)); CreateFlight(companyToken, createFlightUrl, new Flight(company.Id, (int)adminFacade.GetCountryByName("Israel").Id, (int)adminFacade.GetCountryByName("Israel").Id, DateTime.Now, DateTime.Now + TimeSpan.FromHours(3), 150)); IList <Flight> flights = GetAllFlightsForCurrentCompany(companyToken, getAllFlightsUrl); Assert.AreNotEqual(flights, null); Assert.AreEqual(flights.Count, 1); }
public TestCenter() { adminFacade = new LoggedInAdministratorFacade(); adminToken = new LoginToken <Administrator> { User = new Administrator(FlyingCenterConfig.ADMIN_NAME, FlyingCenterConfig.ADMIN_PASSWORD) }; adminFacade.CreateNewCountry(adminToken, new Country() { Country_Name = "Israel", }); airlineFacade = new LoggedInAirlineFacade(); airlineToken = new LoginToken <AirlineCompany> { User = new AirlineCompany("TestAirline", "Airline " + UserTest(), "123", (int)adminFacade.GetCountryByName("Israel").Id) }; adminFacade.CreateNewAirline(adminToken, airlineToken.User); airlineToken.User = adminFacade.GetAirlineByUserName(airlineToken.User.User_Name); customerFacade = new LoggedInCustomerFacade(); customerToken = new LoginToken <Customer> { User = new Customer("TestCustomer", "Ben Sadon", UserTest(), "123", "Neria 28", "050", "3317") }; adminFacade.CreateNewCustomer(adminToken, customerToken.User); customerToken.User = adminFacade.GetCustomerByUserName(adminToken, customerToken.User.User_Name); }
/// <summary> /// Function That Given Random Company For All Test Functions. /// </summary> /// <returns>AirlineCompany</returns> public AirlineCompany CreateRandomCompany() { return(new AirlineCompany(GetRandomNameForTestUsers(), "Airline " + GetRandomNameForTestUsers(), "123", (int)adminFacade.GetCountryByName("Israel").Id)); }
/// <summary> /// Constractor Of Test Center To Create Facade And Token For Basic Users. /// </summary> public TestCenter() { adminFacade = new LoggedInAdministratorFacade(); adminToken = FlyingCenterConfig.basicToken; adminFacade.CreateNewCountry(adminToken, new Country() { Country_Name = "Israel", }); airlineFacade = new LoggedInAirlineFacade(); airlineToken = new LoginToken <AirlineCompany> { User = new AirlineCompany(GetRandomNameForTestUsers(), "Airline " + GetRandomNameForTestUsers(), "123", (int)adminFacade.GetCountryByName("Israel").Id) }; adminFacade.CreateNewAirline(adminToken, airlineToken.User); airlineToken.User = adminFacade.GetAirlineByUserName(adminToken, airlineToken.User.User_Name); customerFacade = new LoggedInCustomerFacade(); customerToken = new LoginToken <Customer> { User = new Customer("TestCustomer", "Ben Sadon", "Customer" + "Customer" + GetRandomNameForTestUsers(), "123", "Neria 28", "050", "3317") }; adminFacade.CreateNewCustomer(adminToken, customerToken.User); customerToken.User = adminFacade.GetCustomerByUserName(adminToken, customerToken.User.User_Name); }
// Create And Log As Airline For The Tests. static public void CreateAndLogAsAirline(out LoginToken <AirlineCompany> token, out LoggedInAirlineFacade facade) { facade = new LoggedInAirlineFacade(); token = new LoginToken <AirlineCompany> { User = new AirlineCompany { Airline_Name = "TestAirline", User_Name = UserTest(), Password = "******", Country_Code = defaultFacade.GetCountryByName("Israel").Id } }; defaultFacade.CreateNewAirline(defaultToken, token.User); token.User = defaultFacade.GetAirlineByUserName(defaultToken, token.User.User_Name); }
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"); }