Exemplo n.º 1
0
        public async Task GetJurisdictionsList_FilterByMultipleTypes_JurisdictionsOfTypes()
        {
            var country = new CountryEntity {
                era_countrycode = "c1", era_name = "c_c", era_countryid = "1", era_isocountrycode = "c1"
            };
            var stateProvince = new StateProvinceEntity {
                era_code = "s1", era_name = "s_a", era_provinceterritoriesid = "1_1", _era_relatedcountry_value = country.era_countryid
            };
            IEnumerable <JurisdictionEntity> jurisdictions = new[]
            {
                new JurisdictionEntity {
                    era_jurisdictionid = "j1", era_jurisdictionname = "j2", era_type = JurisdictionType.City.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince.era_provinceterritoriesid
                },
                new JurisdictionEntity {
                    era_jurisdictionid = "j2", era_jurisdictionname = "j3", era_type = JurisdictionType.District.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince.era_provinceterritoriesid
                },
                new JurisdictionEntity {
                    era_jurisdictionid = "j3", era_jurisdictionname = "j1", era_type = JurisdictionType.DistrictMunicipality.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince.era_provinceterritoriesid
                },
            };
            var mockedListsRepo = new Mock <IListsRepository>();

            mockedListsRepo.Setup(m => m.GetCountriesAsync()).Returns(Task.FromResult(new[] { country }.AsEnumerable()));
            mockedListsRepo.Setup(m => m.GetStateProvincesAsync()).Returns(Task.FromResult(new[] { stateProvince }.AsEnumerable()));
            mockedListsRepo.Setup(m => m.GetJurisdictionsAsync()).Returns(Task.FromResult(jurisdictions));
            var provider = new ListsProvider(mockedListsRepo.Object);

            var result = await provider.GetJurisdictionsAsync(new[] { JurisdictionType.City, JurisdictionType.District }, stateProvince.era_code, country.era_countrycode);

            Assert.Equal(2, result.Count());
        }
Exemplo n.º 2
0
        public async Task GetJurisdictionsList_AllActiveJurisdictionInCountryAndStateProvince()
        {
            var country1 = new CountryEntity {
                era_countrycode = "c1", era_name = "c_1", era_countryid = "1", era_isocountrycode = "c1"
            };
            var stateProvince1_1 = new StateProvinceEntity {
                era_code = "s1", era_name = "s_a", era_provinceterritoriesid = "1", _era_relatedcountry_value = country1.era_countryid
            };
            var stateProvince1_2 = new StateProvinceEntity {
                era_code = "s2", era_name = "s_b", era_provinceterritoriesid = "2", _era_relatedcountry_value = country1.era_countryid
            };
            var country2 = new CountryEntity {
                era_countrycode = "c2", era_name = "c_2", era_countryid = "2", era_isocountrycode = "c2"
            };
            var stateProvince2_1 = new StateProvinceEntity {
                era_code = "s1", era_name = "s_a", era_provinceterritoriesid = "3", _era_relatedcountry_value = country2.era_countryid
            };
            IEnumerable <JurisdictionEntity> jurisdictions = new[]
            {
                new JurisdictionEntity {
                    era_jurisdictionid = "1", era_jurisdictionname = "j1", era_type = JurisdictionType.City.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince1_1.era_provinceterritoriesid
                },
                new JurisdictionEntity {
                    era_jurisdictionid = "2", era_jurisdictionname = "j2", era_type = JurisdictionType.District.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince1_1.era_provinceterritoriesid
                },
                new JurisdictionEntity {
                    era_jurisdictionid = "3", era_jurisdictionname = "j3", era_type = JurisdictionType.DistrictMunicipality.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince1_1.era_provinceterritoriesid
                },
                new JurisdictionEntity {
                    era_jurisdictionid = "4", era_jurisdictionname = "j4", era_type = JurisdictionType.City.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince1_1.era_provinceterritoriesid
                },
                new JurisdictionEntity {
                    era_jurisdictionid = "5", era_jurisdictionname = "j5", era_type = JurisdictionType.City.GetHashCode().ToString(), _era_relatedprovincestate_value = stateProvince2_1.era_provinceterritoriesid
                },
            };
            var mockedListsRepo = new Mock <IListsRepository>();

            mockedListsRepo.Setup(m => m.GetCountriesAsync()).Returns(Task.FromResult(new[] { country1, country2 }.AsEnumerable()));
            mockedListsRepo.Setup(m => m.GetStateProvincesAsync()).Returns(Task.FromResult(new[] { stateProvince1_1, stateProvince1_2, stateProvince2_1 }.AsEnumerable()));
            mockedListsRepo.Setup(m => m.GetJurisdictionsAsync()).Returns(Task.FromResult(jurisdictions));
            var provider = new ListsProvider(mockedListsRepo.Object);

            var result = await provider.GetJurisdictionsAsync(null, stateProvince1_1.era_code, country1.era_countrycode);

            Assert.Equal(jurisdictions.Count(j => j._era_relatedprovincestate_value == stateProvince1_1.era_provinceterritoriesid), result.Count());
        }
 protected AddressEntity(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     if (SerializationHelper.Optimization != SerializationOptimization.Fast)
     {
         _businessEntityAddresses = (EntityCollection <BusinessEntityAddressEntity>)info.GetValue("_businessEntityAddresses", typeof(EntityCollection <BusinessEntityAddressEntity>));
         _salesOrderHeaders       = (EntityCollection <SalesOrderHeaderEntity>)info.GetValue("_salesOrderHeaders", typeof(EntityCollection <SalesOrderHeaderEntity>));
         _salesOrderHeaders1      = (EntityCollection <SalesOrderHeaderEntity>)info.GetValue("_salesOrderHeaders1", typeof(EntityCollection <SalesOrderHeaderEntity>));
         _stateProvince           = (StateProvinceEntity)info.GetValue("_stateProvince", typeof(StateProvinceEntity));
         if (_stateProvince != null)
         {
             _stateProvince.AfterSave += new EventHandler(OnEntityAfterSave);
         }
         this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
     }
     // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
     // __LLBLGENPRO_USER_CODE_REGION_END
 }
Exemplo n.º 4
0
 public static StateProvinceCollection GetStateProvinceCollection()
 {
     return(StateProvinceEntity.GetStateProvinceCollection());
 }