示例#1
0
        protected override void Context()
        {
            base.Context();
            _organism   = new Organism();
            _individual = A.Fake <Individual>();
            _origin     = new OriginData();
            var cm1 = new CalculationMethod {
                Id = "1", Name = "1"
            };

            _cmDTO1 = new CategoryCalculationMethodDTO();
            A.CallTo(_calculationMethodDTOMapper).WithReturnType <CategoryCalculationMethodDTO>().Returns(_cmDTO1);
            _origin.Species       = new Species();
            _origin.Population    = new SpeciesPopulation();
            _origin.SubPopulation = new SubPopulation();
            _origin.AddCalculationMethod(cm1);
            _origin.Gender      = new Gender();
            _subPopulationDTO   = A.Fake <IEnumerable <CategoryParameterValueVersionDTO> >();
            _parameterAge       = A.Fake <IParameter>().WithName(CoreConstants.Parameters.AGE);
            _parameterHeight    = A.Fake <IParameter>().WithName(CoreConstants.Parameters.HEIGHT);
            _parameterWeight    = A.Fake <IParameter>().WithName(CoreConstants.Parameters.WEIGHT);
            _parameterAgeDTO    = A.Fake <ParameterDTO>();
            _parameterHeightDTO = A.Fake <ParameterDTO>();
            _parameterWeightDTO = A.Fake <ParameterDTO>();
            A.CallTo(() => _subPopulationDTOMapper.MapFrom(_origin.SubPopulation)).Returns(_subPopulationDTO);
            A.CallTo(() => _parameterMapper.MapAsReadWriteFrom(_parameterAge)).Returns(_parameterAgeDTO);
            A.CallTo(() => _parameterMapper.MapAsReadWriteFrom(_parameterHeight)).Returns(_parameterHeightDTO);
            A.CallTo(() => _parameterMapper.MapAsReadWriteFrom(_parameterWeight)).Returns(_parameterWeightDTO);
            A.CallTo(() => _individual.Organism).Returns(_organism);

            _individual.OriginData = _origin;
            _organism.AddChildren(_parameterWeight, _parameterHeight, _parameterAge);
        }
        private Model.OriginData originDataFrom(PopulationSettings batchPopulationSettings)
        {
            //create default individual based on given data
            var batchOriginData = new OriginData
            {
                Species    = batchPopulationSettings.Species,
                Population = batchPopulationSettings.Population
            };

            batchPopulationSettings.AllCalculationMethods.KeyValues.Each(kv => batchOriginData.AddCalculationMethod(kv.Key, kv.Value));

            return(_originDataMapper.MapFrom(batchOriginData));
        }