コード例 #1
0
        public void Test_GetCountries()
        {
            var countriesHandler = new CountriesHandler(new Cache());
            var _countries       = countriesHandler.GetCountries();

            Assert.IsTrue(_countries != null);
            Assert.IsTrue(_countries.Count > 0);
        }
コード例 #2
0
        public void Test_GetCountriesValues()
        {
            var countriesHandler = new CountriesHandler(new Cache());
            var _countries       = countriesHandler.GetCountries();

            Assert.IsTrue(_countries.ContainsKey("EG"));
            Assert.IsTrue(!_countries.ContainsKey("Egypt123"));
        }
コード例 #3
0
 public ApplicationInterface()
 {
     while (true)
     {
         Console.WriteLine("show — get country data from json;\nall — show all saved countries\nq — exit.\n");
         UserAnswer = Console.ReadLine();
         if (UserAnswer == "show")
         {
             Console.WriteLine("Type country name:\n");
             CountryName = Console.ReadLine();
             var showCountry = new CountryData();
             showCountry.ShowCountryDataFromJson(CountryName);
             if (showCountry.countryExist == true)
             {
                 Console.WriteLine("\nDo you want to save it to the database? Y/n");
                 if (Console.ReadLine() == "Y")
                 {
                     var addCountry = new CountriesHandler();
                     addCountry.NewCountry(CountryName);
                     Console.WriteLine("Country added");
                 }
                 else if (Console.ReadLine() == "n")
                 {
                     Console.WriteLine("Press enter to return to main menu");
                     Console.ReadLine();
                 }
             }
         }
         else if (UserAnswer == "all")
         {
             var dbCountries = new DataBaseCountries();
             dbCountries.PrintAllCountries();
         }
         else if (UserAnswer == "q")
         {
             Environment.Exit(0);
         }
         else
         {
             Console.WriteLine("There is no command " + UserAnswer + "\n");
         }
     }
 }