public void GetCountryCodeAsyncTest() { var sut = new CountryCodeService(); IDictionary<string, string> countryCodes = sut.GetCountryCodesAsync().Result; Assert.IsTrue(countryCodes.Any()); }
public void ImportCountryCodesIntoDB() { var countryCodeService = new CountryCodeService(); IDictionary<string, string> countryCodes = countryCodeService.GetCountryCodesAsync().Result; using (var db = new DBContext()) { foreach (Country country in db.Countries) { string countryCode = countryCodes.SingleOrDefault(x => x.Key == country.Name).Value; if (countryCode != null) { country.CountryCode = countryCode; } } db.SaveChanges(); } }