/// <summary> /// Retrieves a Country object using the provided country code /// </summary> /// <param name="countryCode">Country code representing the country</param> /// <returns>A Country object</returns> public Country CreateCountry(string countryCode) { var normalizedCountryCode = _countryCodeValidator.GetNormalizedCountryCode(countryCode); Iso3166Country iso3166Country; if (Iso3166Countries.Countries.TryGetValue(normalizedCountryCode, out iso3166Country) == false) { throw new ArgumentException(string.Format("Unsupported country code: {0}", countryCode)); } if (iso3166Country.Status != Iso3166CountryCodeStatus.OfficiallyAssigned && iso3166Country.Status != Iso3166CountryCodeStatus.TransitionallyReserved) { throw new ArgumentException(string.Format("Country: {0}, is in status {1}", countryCode, iso3166Country.Status)); } var countryName = iso3166Country.CountryName; return(Countries.GetOrAdd(normalizedCountryCode, key => new Country(normalizedCountryCode, countryName))); }
/// <summary> /// Retrieves a Country object using the provided country code and normalizer /// </summary> /// <param name="countryCode">Country code representing the country</param> /// <returns>A Country object</returns> public Country CreateCountry(string countryCode) { var normalizedCountryCode = _countryCodeValidator.GetNormalizedCountryCode(countryCode); return(Countries.GetOrAdd(normalizedCountryCode, key => new Country(normalizedCountryCode))); }
public void GetNormalizedCountryCode_ReturnsValidCountryCode(string input, string output) { Assert.AreEqual(output, IsoValidator.GetNormalizedCountryCode(input)); }