public UserInterface(string connectionString) { this.spaceDAL = new SpaceSqlDAL(connectionString); this.venueDAL = new VenueSqlDAL(connectionString); this.categoryDAL = new CategorySqlDAL(connectionString); this.reservationDAL = new ReservationSqlDAL(connectionString); this.cityDAL = new CitySqlDAL(connectionString); }
public void GetCitiesByCountryCodeTest() { // Arrange CitySqlDAL cityDal = new CitySqlDAL(connectionString); //Act List <City> cities = cityDal.GetCitiesByCountryCode("ABC"); //<-- use our dummy country //Assert Assert.AreEqual(1, cities.Count); // We should only have one city in ABC country Assert.AreEqual(cityId, cities[0].CityId); // We created the city ahead of time and know the id to check for }
private void GetCitiesByCountryCode() { string countryCode = CLIHelper.GetString("Enter the country code that you want to retrieve:"); CitySqlDAL dal = new CitySqlDAL(DatabaseConnectionString); List <City> cities = dal.GetCitiesByCountryCode(countryCode); Console.WriteLine(); Console.WriteLine($"Printing {cities.Count} cities for {countryCode}"); foreach (var city in cities) { Console.WriteLine(city); } }
private void GetCitiesByCountryCode() { string countryCode = CLIHelper.GetString("Enter the country code that you want to retrieve:"); CitySqlDAL dal = new CitySqlDAL(DatabaseConnectionString); List <City> cities = dal.GetCitiesByCountryCode(countryCode); Console.WriteLine(); Console.WriteLine($"Printing {cities.Count} cities for {countryCode}"); foreach (City c in cities) { Console.WriteLine(c.CityId.ToString().PadRight(6) + c.Name.PadRight(30) + c.District.PadRight(30) + c.Population.ToString("N0").PadRight(10)); } }
public void CitiesByCountryCode_Country_With_Cities() { // Rolls back the data when done with the test. using (TransactionScope transaction = new TransactionScope()) { //Arrange CountrySqlDALTests.InsertFakeCountry("JRT", "Joshtopia", "North America"); int cityId = CitySqlDALTests.InsertFakeCity("Joshville", "JRT"); CitySqlDAL testClass = new CitySqlDAL(connectionString); //Act List <City> cities = testClass.GetCitiesByCountryCode("JRT"); //Assert Assert.AreEqual(1, cities.Count); Assert.AreEqual("Joshville", cities[0].Name); Assert.AreEqual(cityId, cities[0].CityId); } }
public void RunCLI() { try { CitySqlDAL cityDal = new CitySqlDAL(DatabaseConnectionString); City city = new City(); city.CityId = 1; city.CountryCode = "GBR"; city.District = "Liverpool"; city.Name = "The City of Jakitude"; city.Population = -1; cityDal.AddCity(city); } catch (Exception ex) { Console.WriteLine("Hey we had an exception."); } PrintHeader(); PrintMenu(); while (true) { string command = Console.ReadLine(); Console.Clear(); switch (command.ToLower()) { case Command_GetAllContinentNames: GetContinentNames(); break; case Command_CountriesInNorthAmerica: GetCountriesInNorthAmerica(); break; case Command_CitiesByCountryCode: GetCitiesByCountryCode(); break; case Command_LanguagesByCountryCode: GetLanguagesForCountry(); break; case Command_AddNewLanguage: AddNewLanguage(); break; case Command_RemoveLanguage: RemoveLanguage(); break; case Command_Quit: Console.WriteLine("Thank you for using the world geography cli app"); return; default: Console.WriteLine("The command provided was not a valid command, please try again."); break; } PrintMenu(); } }