public void Can_Retrieve_A_List_Of_Countries_Without_Duplicates() { //// Arrange //// Act var countries = _storeSettingService.GetAllCountries(); foreach (var country in countries.OrderBy(x => x.CountryCode)) { Console.WriteLine("{0} {1}", country.CountryCode, country.Name); } var distinctCodes = countries.Select(x => x.CountryCode).Distinct(); //// Assert Assert.AreEqual(countries.Count(), distinctCodes.Count()); }
/// <summary> /// Returns a list of all countries that can be assigned to a shipment /// </summary> /// <returns>A collection of <see cref="ICountry"/></returns> public IEnumerable <ICountry> GetAllowedShipmentDestinationCountries() { var shipCountries = GatewayProviderService.GetAllShipCountries().ToArray(); var elseCountries = shipCountries.Where(x => x.CountryCode == "ELSE").ToArray(); if (elseCountries.Any()) { // get a list of all providers associated with the else countries var providers = new List <IShippingGatewayProvider>(); foreach (var ec in elseCountries) { providers.AddRange(GetGatewayProvidersByShipCountry(ec)); } if (providers.Any(x => x.ShipMethods.Any())) { return(_storeSettingService.GetAllCountries()); } } var countries = GatewayProviderService.GetAllShipCountries().Where(x => x.CountryCode != "ELSE").Select(x => _storeSettingService.GetCountryByCode(x.CountryCode)).Where(x => x != null); return(countries.Distinct()); }
/// <summary> /// Gets a list of available countries for the billing address. /// </summary> /// <returns> /// The <see cref="IEnumerable{SelectListItem}"/>. /// </returns> protected override IEnumerable <SelectListItem> GetCountrySelectListItems() { var countries = _storeSettingService.GetAllCountries(); return(GetSelectListItems(countries)); }
/// <summary> /// Responsible for initializing the controller. /// </summary> private void Initialize() { _allCountries = new Lazy <IEnumerable <ICountry> >(() => _storeSettingService.GetAllCountries().OrderBy(x => x.Name)); _shippingCountries = new Lazy <IEnumerable <ICountry> >(() => _gatewayContext.Shipping.GetAllowedShipmentDestinationCountries().OrderBy(x => x.Name)); }