public void GetCountriesByContinent_Should_ReturnCorrectNumberOfCountries(string continent, int expectedCount) { CountrySqlDAO dao = new CountrySqlDAO(ConnectionString); IList <Country> countries = dao.GetCountries(continent); Assert.AreEqual(expectedCount, countries.Count); }
static void Main(string[] args) { // Select all countries //GetAllCountries(); // Get a count of all countries //GetCountryCount(); // Select cities that belong to a country code //GetCitiesForCountryCode("USA"); //Console.ReadKey(); //return; //IConfigurationBuilder builder = new ConfigurationBuilder() // .SetBasePath(Directory.GetCurrentDirectory()) // .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); //IConfigurationRoot configuration = builder.Build(); //string connectionString = configuration.GetConnectionString("World"); ICityDAO cityDAO = null; ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ILanguageDAO languageDAO = null; WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
static void Main(string[] args) { // This code reads the connection string from appsettings.json IConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); // TODO 00: Create a Model for Country to go with the City model we already have // TODO 01: Create a CountrySqlDAO class (GetCountries, GetCountries(continent), GetCountry(code)) // TODO 01a: Create an ICountryDAO interface ICountryDAO countryDAO = new CountrySqlDAO(connectionString); // TODO 07: Create a CitySqlDAO class (GetCitiesByCountryCode) // TODO 07a: Create an ICityDAO interface // TODO 02b: Create a WorldDBMenu, passing in the country dao, and Run it WorldDBMenu menu = new WorldDBMenu(countryDAO); menu.Run(); // Say goodbye to the user... Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("Goodbye..."); Thread.Sleep(1500); }
static void Main(string[] args) { // This code reads the connection string from appsettings.json // Add the connection string to appsettings.json and un-comment the following lines to read the configuration IConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); // TEMPORARY: DB EXAMPLE (vanilla, no DAO) //ReadCities(); //return; ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ICityDAO cityDAO = new CitySqlDAO(connectionString); // TODO 14a: Create a Model for CountryLanguage // TODO 14b: Create a CountryLanguageSqlDAO class (GetLanguages(string countryCode)) // TODO 14c: Create an ICountryLanguageDAO interface ICountryLanguageDAO countryLanguageDAO = new CountryLanguageSqlDAO(connectionString); // Create a WorldDBMenu, passing in the country dao, and Run it WorldDBMenu menu = new WorldDBMenu(countryDAO, cityDAO, countryLanguageDAO); menu.Show(); // Say goodbye to the user... Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("Goodbye..."); Thread.Sleep(1500); }
public void Arrange() { //arrange //Establish the "known state" of the database SetupDB(); //Create and instance of CountrySqlDAO this.dao = new CountrySqlDAO(connectionString); }
static void Main(string[] args) { ICityDAO cityDAO = new CitySqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); ICountryDAO countryDAO = new CountrySqlDAO(@"Server=.\SQLExpress;Database=World;Trusted_Connection=True;"); ILanguageDAO languageDAO = new LanguageSqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
public void GetCountriesTest_Should_ReturnAllCountries() { // Arrange CountrySqlDAO dao = new CountrySqlDAO(ConnectionString); // Act IList <Country> countries = dao.GetCountries(); // Assert Assert.AreEqual(1, countries.Count); }
public void GetCountriesByContinent_Should_ReturnCorrectNumberOfCountries(string continent, int expectedCount) { // Arrange CountrySqlDAO dao = new CountrySqlDAO(this.connectionString); // Act IList <Country> list = dao.GetCountries(continent); // Assert - Country count Assert.AreEqual(expectedCount, list.Count); }
public void GetCountriesTest_Should_ReturnAllCountries() { // Arrange CountrySqlDAO dao = new CountrySqlDAO(this.connectionString); // Act IList <Country> list = dao.GetCountries(); // Assert - Country count Assert.AreEqual(3, list.Count); }
public void GetCountriesByContinent_Should_ReturnCorrectNumberOfCountries(string continent, int expectedCount) { // Arrange CountrySqlDAO country = new CountrySqlDAO(ConnectionString); // Act IList <Country> countryList = country.GetCountries(continent); // Assert Assert.AreEqual(expectedCount, countryList.Count); }
public void GetCountriesInNorthAmericaTest() { // Arrange CountrySqlDAO countrySqlDAO = new CountrySqlDAO(ConnectionString); // Act IList <Country> countries = countrySqlDAO.GetCountries("North America"); // Assert Assert.IsTrue(countries.Count > 0); }
public void GetCountriesTest_Should_ReturnAllCountries() { // Arrange CountrySqlDAO dao = new CountrySqlDAO(ConnectionString); // Act IList <Country> countries = dao.GetCountries(); // Assert Assert.AreEqual(numCountries, countries.Count); // Some will argue this is sufficient Assert.IsTrue(countries.Count > 0); }
static void Main(string[] args) { // This code reads the connection string from appsettings.json // TODO 03: Add the connection string to appsettings.json and un-comment the following lines to read the configuration IConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); // TEMPORARY: DB EXAMPLE (vanilla, no DAO) //ReadCities(); //return; /* CREATED JUST TO TEST MENU * CountrySqlDAO dao = new CountrySqlDAO(connectionString); * List<Country> list = dao.GetCountries("Asia"); * * Country country = dao.GetCountry("ZZZ"); * * country = dao.GetCountry("USA"); */ // TODO 04a: Create a Model for Country to go with the City model we already have // TODO 04b: Create a CountrySqlDAO class (GetCountries, GetCountries(continent), GetCountry(code)) // TODO 04c: Create an ICountryDAO interface // TODO 10: Create a CitySqlDAO class (GetCitiesByCountryCode) // TODO 10a: Create an ICityDAO interface // TODO 14a: Create a Model for CountryLanguage // TODO 14b: Create a CountryLanguageSqlDAO class (GetLanguages(string countryCode)) // TODO 14c: Create an ICountryLanguageDAO interface ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ICityDAO cityDAO = new CitySqlDAO(connectionString); // TODO 05b: Create a WorldDBMenu, passing in the country dao, and Run it WorldDBMenu menu = new WorldDBMenu(countryDAO, cityDAO); menu.Show(); // Say goodbye to the user... Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("Goodbye..."); Thread.Sleep(1500); }
static void Main(string[] args) { IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); ICityDAO cityDAO = new CitySqlDAO(connectionString); ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ILanguageDAO languageDAO = new LanguageSqlDAO(connectionString); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
public IActionResult CreateCountry(Country c) { //6. have it really create a country //Not DEPENDENCY INJECTION try { ICountryDAO countryDAO = new CountrySqlDAO(@"Data Source=.\sqlexpress;Initial Catalog=world;Integrated Security=true;"); countryDAO.AddCountry(c); } catch (Exception e) { //SINCE our sql is broke as a joke we should return oops return(RedirectToAction("oops")); } //5. path of least resistance is to send them to the dora page return(RedirectToAction("Confirmation")); }
static void Main(string[] args) { //IConfigurationBuilder builder = new ConfigurationBuilder() // .SetBasePath(Directory.GetCurrentDirectory()) // .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); //IConfigurationRoot configuration = builder.Build(); //string connectionString = configuration.GetConnectionString("World"); ICityDAO cityDAO = new CitySqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); ICountryDAO countryDAO = new CountrySqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); ILanguageDAO languageDAO = new LanguageSqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
static void Main(string[] args) { //IConfigurationBuilder builder = new ConfigurationBuilder() // .SetBasePath(Directory.GetCurrentDirectory()) // .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); //IConfigurationRoot configuration = builder.Build(); //string connectionString = configuration.GetConnectionString("World"); ICityDAO cityDAO = new CitySqlDAO(@"Data Source=.\SQLEXPRESS;Initial Catalog=World;Integrated Security=True"); ICountryDAO countryDAO = new CountrySqlDAO(@"Data Source=.\SQLEXPRESS;Initial Catalog=World;Integrated Security=True"); ILanguageDAO languageDAO = null; WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
static void Main(string[] args) { IConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); ICityDAO cityDAO = new CitySqlDAO(connectionString); ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ILanguageDAO languageDAO = new LanguageSqlDAO(connectionString); WorldDBMenu menu = new WorldDBMenu(cityDAO, countryDAO, languageDAO); menu.Run(); Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("Goodbye..."); Thread.Sleep(1500); }
static void Main(string[] args) { // TODO: This is how we load a configuration file and get the connection string IConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); // TODO: This gets a custom value from the Config file bool useFileDAO = configuration.GetSection("DAO").GetValue <bool>("UseFileDAO", false); // TODO: Here, the Main method creates instances of DAOs which will be "injected" into the menu (CLI). ICityDAO cityDAO; ICountryDAO countryDAO; ILanguageDAO languageDAO; if (useFileDAO) { // TODO: This is a COMPLETELY different set of DAOs which implement the SAME interfaces cityDAO = new CityFileDAO(@"..\..\..\City_Data.txt"); countryDAO = new CountryFileDAO(@"..\..\..\Country_Data.txt"); languageDAO = new LanguageFileDAO(@"..\..\..\Language_Data.txt"); } else { cityDAO = new CitySqlDAO(connectionString); countryDAO = new CountrySqlDAO(connectionString); languageDAO = new LanguageSqlDAO(connectionString); } // TODO: Here, we create the menu, and "inject" the DAOs we want to use WorldDBMenu menu = new WorldDBMenu(cityDAO, countryDAO, languageDAO); menu.Run(); Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("Goodbye..."); Thread.Sleep(1500); }
public void GetCountryHasCorrectValues() { //arrange CountrySqlDAO dao = new CountrySqlDAO(ConnectionString); //act IList <Country> countries = dao.GetCountries("North America"); string expectedRegion = "Region"; string actualRegion = ""; foreach (Country country in countries) { if (country.Code == "USA") { actualRegion = country.Region; } } //ASSERT Assert.AreEqual(expectedRegion, actualRegion); }
static void Main(string[] args) { // The code in the region reads "appsettings" so that the connection string can: // 1) be in one place in the code // 2) can be modified in the bin/debug.netcoreapp2.1 folder without having to // change and recompile the program #region Get Configuration String IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); #endregion ICityDAO cityDAO = new CitySqlDAO(connectionString); ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ILanguageDAO languageDAO = new LanguageSqlDAO(connectionString); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
public WorldGeographyCLI(string connectionString) { this.cityDAO = new CitySqlDAO(connectionString); this.languageDAO = new LanguageSqlDAO(connectionString); this.countryDAO = new CountrySqlDAO(connectionString); }