示例#1
0
 protected override void Context()
 {
     _genderRepository = A.Fake <IGenderRepository>();
     A.CallTo(() => _genderRepository.FindByIndex(1)).Returns(_male);
     A.CallTo(() => _genderRepository.FindByIndex(2)).Returns(_female);
     _populationRepository = A.Fake <IPopulationRepository>();
     A.CallTo(() => _populationRepository.FindByIndex(0)).Returns(_population);
     _logger = A.Fake <IImportLogger>();
     sut     = new IndividualPropertiesCacheImporter(_genderRepository, _populationRepository);
 }
示例#2
0
        private void addCovariates(IndividualPropertiesCache individualPropertiesCache, string parameterPath, IEnumerable <double> values)
        {
            if (string.Equals(parameterPath, CoreConstants.Parameters.RACE_INDEX))
            {
                individualPropertiesCache.AddPopulations(values.Select(index => _populationRepository.FindByIndex((int)index)).ToList());
            }

            else if (string.Equals(parameterPath, CoreConstants.Parameters.GENDER))
            {
                individualPropertiesCache.AddGenders(values.Select(index => _genderRepository.FindByIndex((int)index)).ToList());
            }
        }
        private CovariateValues populationCovariateFrom(CovariateValues originalCovariateValues)
        {
            if (originalCovariateValues.Count == 0)
            {
                return(new CovariateValues(Constants.Population.POPULATION));
            }

            //Not a number => Already to the newest format
            var firstValue = originalCovariateValues.ValueAt(0);

            if (!int.TryParse(firstValue, out _))
            {
                return(originalCovariateValues);
            }

            // needs conversion
            var races = originalCovariateValues.Values.Select(x => _populationRepository.FindByIndex(int.Parse(x))).Select(x => x.Name).ToList();

            return(new CovariateValues(Constants.Population.POPULATION, races));
        }