diff --git a/src/CountryData.Standard/CountryHelper.cs b/src/CountryData.Standard/CountryHelper.cs index 6dcb817..435c039 100644 --- a/src/CountryData.Standard/CountryHelper.cs +++ b/src/CountryData.Standard/CountryHelper.cs @@ -9,14 +9,14 @@ namespace CountryData.Standard { public class CountryHelper { - private readonly IEnumerable _Countries; - private const string strFileName = "CountryData.Standard.data.json"; + private readonly IEnumerable _countries; + private const string StrFileName = "CountryData.Standard.data.json"; public CountryHelper() { - var json = GetJsonData(strFileName); - _Countries = JsonConvert.DeserializeObject>(json); - foreach (var country in _Countries) + var json = GetJsonData(StrFileName); + _countries = JsonConvert.DeserializeObject>(json); + foreach (var country in _countries) { country.CountryFlag = GetCountryEmojiFlag(country.CountryShortCode); } @@ -49,7 +49,7 @@ private string GetJsonData(string path) /// IEnumerable public virtual IEnumerable GetCountryData() { - return _Countries; + return _countries; } @@ -60,7 +60,7 @@ public virtual IEnumerable GetCountryData() /// Country public Country GetCountryByCode(string shortCode) { - return _Countries.SingleOrDefault(c => c.CountryShortCode == shortCode); + return _countries.SingleOrDefault(c => c.CountryShortCode == shortCode); } /// @@ -81,7 +81,7 @@ public string GetCountryEmojiFlag(string shortCode) /// List a list of regions public List GetRegionByCountryCode(string ShortCode) { - return _Countries.Where(x => x.CountryShortCode == ShortCode) + return _countries.Where(x => x.CountryShortCode == ShortCode) .Select(r => r.Regions).FirstOrDefault() .ToList(); } @@ -90,7 +90,7 @@ public List GetRegionByCountryCode(string ShortCode) /// Gets the list of all countries in the worlld /// /// IEnumerable countries - public IEnumerable GetCountries() => _Countries.Select(c => c.CountryName); + public IEnumerable GetCountries() => _countries.Select(c => c.CountryName); @@ -102,7 +102,7 @@ public List GetRegionByCountryCode(string ShortCode) /// string public string GetPhoneCodeByCountryShortCode(string shortCode) { - var country = _Countries.SingleOrDefault(c => c.CountryShortCode == shortCode); + var country = _countries.SingleOrDefault(c => c.CountryShortCode == shortCode); return country?.PhoneCode; } @@ -115,8 +115,8 @@ public string GetPhoneCodeByCountryShortCode(string shortCode) /// Country public IEnumerable GetCountryByPhoneCode(string phoneCode) { - var Country = _Countries.Where(c => c.PhoneCode == phoneCode); - return Country; + var country = _countries.Where(c => c.PhoneCode == phoneCode); + return country; } @@ -127,7 +127,7 @@ public IEnumerable GetCountryByPhoneCode(string phoneCode) /// An IEnumerable of Currency objects associated with the specified country. public IEnumerable GetCurrencyCodesByCountryCode(string shortCode) { - return _Countries.Where(x => x.CountryShortCode == shortCode) + return _countries.Where(x => x.CountryShortCode == shortCode) .SelectMany(c => c.Currency) .ToList(); } @@ -141,12 +141,12 @@ public IEnumerable GetCurrencyCodesByCountryCode(string shortCode) /// Thrown when the country data is not initialized. public IEnumerable GetCountryByCurrencyCode(string currencyCode) { - if (_Countries == null) + if (_countries == null) { throw new InvalidOperationException("Country data is not initialized."); } - return _Countries.Where(c => c.Currency != null && c.Currency.Exists(currency => currency.Code == currencyCode)); + return _countries.Where(c => c.Currency != null && c.Currency.Exists(currency => currency.Code == currencyCode)); } diff --git a/test/CountryData.UnitTests/CountryHelperTests.cs b/test/CountryData.UnitTests/CountryHelperTests.cs index b3738c4..8ade22a 100644 --- a/test/CountryData.UnitTests/CountryHelperTests.cs +++ b/test/CountryData.UnitTests/CountryHelperTests.cs @@ -198,7 +198,7 @@ public void GetCountryByCurrencyCode_WhenCountryDataIsNotInitialized_ShouldThrow { // Arrange var countryHelper = new CountryHelper(); - var field = typeof(CountryHelper).GetField("_Countries", BindingFlags.NonPublic | BindingFlags.Instance); + var field = typeof(CountryHelper).GetField("_countries", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(countryHelper, null); // Act