コード例 #1
0
        public async void AllTestAsync()
        {
            List <string> filters = new List <string> ()
            {
                Filters.Name
            };
            List <Country> allCountries = await RestCountry.AllAsync(filters);

            List <Country> countries = await RestCountry.AllAsync();

            foreach (Country con in allCountries)
            {
                if (con.Name == "Nepal")
                {
                    _NepalResultFiltered(con);
                }
            }

            foreach (Country con in countries)
            {
                if (con.Name == "Nepal")
                {
                    _NepalResultFull(con);
                }
            }
        }
コード例 #2
0
        public void AllTest()
        {
            List <string> filters = new List <string>()
            {
                Filters.Name
            };
            List <Country> allCountriesFiltered = RestCountry.All(filters);
            List <Country> allCountries         = RestCountry.All();

            foreach (Country con in allCountries)
            {
                if (con.Name == "Nepal")
                {
                    _NepalResultFull(con);
                }
            }

            foreach (Country con in allCountriesFiltered)
            {
                if (con.Name == "Nepal")
                {
                    _NepalResultFiltered(con);
                }
            }
        }
コード例 #3
0
 public static Country ToCountry(this RestCountry restCountry)
 {
     return(new Country
     {
         Name = restCountry.Name,
         Capital = restCountry.capital
     });
 }
コード例 #4
0
        public async void AsyncCodeTest()
        {
            List <Country> con = await RestCountry.CodeAsync("NP");

            foreach (Country c in con)
            {
                _NepalResultFull(c);
            }
        }
コード例 #5
0
        public void CodeTest()
        {
            List <Country> con = RestCountry.Code("NP");

            foreach (Country c in con)
            {
                _NepalResultFull(c);
            }
        }
コード例 #6
0
        /// <summary>
        /// Generates the sentence out of random <see cref="RestCountry"/> properties.
        /// </summary>
        /// <param name="country">The country.</param>
        /// <param name="propertyCount">The property count.</param>
        /// <returns>The generated sentence.</returns>
        private string GenerateSentence(RestCountry country, int propertyCount)
        {
            var propertyPairs     = RestCountryPropertyInfoProvider.GetRandomProperties(country, 3);
            var sentencifiedPairs = propertyPairs.Select(pair => $"{pair.PropertyName} is {pair.Value}");
            var joinedSentence    = string.Join(", ", sentencifiedPairs.Take(propertyCount - 1));

            joinedSentence += $" and {sentencifiedPairs.Last()}";

            return(joinedSentence);
        }
コード例 #7
0
        public void NameTest()
        {
            List <Country> con = RestCountry.Name("ne");

            foreach (Country c in con)
            {
                if (c.Name == "Nepal")
                {
                    _NepalResultFull(c);
                }
            }
        }
コード例 #8
0
        public void AllTest()
        {
            List <string> filters = new List <string> ()
            {
                Filters.Name
            };
            List <Country> allCountriesFiltered = RestCountry.All(filters);
            List <Country> allCountries         = RestCountry.All();
            List <string>  filterByAlphaCode    = new List <string> ()
            {
                Filters.Alpha2Code
            };
            List <Country> alllCountriesAlphaCodeFilter = RestCountry.All(filterByAlphaCode);

            foreach (Country con in allCountries)
            {
                if (con.Name == "Nepal")
                {
                    _NepalResultFull(con);
                }
            }

            foreach (Country con in allCountriesFiltered)
            {
                if (con.Name == "Nepal")
                {
                    _NepalResultFiltered(con);
                }
            }

            foreach (Country con in alllCountriesAlphaCodeFilter)
            {
                if (con.Name == "Nepal")
                {
                    Assert.Equal("NP", con.Alpha2Code);
                }
            }
        }
コード例 #9
0
        public List <Country> CountryTable()
        {
            List <Country> allCountries = RestCountry.All();

            return(allCountries);
        }
 public static IEnumerable <(string PropertyName, string Value)> GetRandomProperties(RestCountry country, int amount)
 {
     return(Properties
            .OrderBy(prop => Random.Next())
            .Take(amount)
            .Select(prop => (prop.Name, prop.GetValue(country).ToString()))
            .ToArray());
 }