Exemplo n.º 1
0
        private void updateFirstAndAddLastEntry(double?lastEntryMinimum = null)
        {
            var values = _numericField.GetValues(_populationDataCollector);

            if (_fixedLimitDTOs.Count == 0)
            {
                _fixedLimitDTOs.Add(newDTO());
            }

            var firstDTO = _fixedLimitDTOs[0];

            firstDTO.CanDelete = false;
            firstDTO.Minimum   = _numericField.ValueInDisplayUnit(values.Min());

            double?minimumInDisplayUnit = null;

            if (lastEntryMinimum != null)
            {
                minimumInDisplayUnit = _numericField.ValueInDisplayUnit(lastEntryMinimum.Value);
            }

            //Last item
            _fixedLimitDTOs.Add(newDTO(canDelete: false, canAdd: false,
                                       maximumInDisplayUnit: _numericField.ValueInDisplayUnit(values.Max()),
                                       maximumEditable: false, minimumInDisplayUnit: minimumInDisplayUnit));
        }
Exemplo n.º 2
0
        public IReadOnlyList <string> GenerateLabels(IPopulationDataCollector populationDataCollector, PopulationAnalysisNumericField numericField, NumberOfBinsGroupingDefinition groupingDefinition)
        {
            var limitsInDisplayUnit = groupingDefinition.Limits.Select(v => convertedValue(numericField, v)).ToList();
            var values = numericField.GetValues(populationDataCollector);

            //add min and max to the limits
            limitsInDisplayUnit.Insert(0, convertedValue(numericField, values.Min()));
            limitsInDisplayUnit.Add(convertedValue(numericField, values.Max()));

            return(GenerateLabels(new LabelGenerationOptions
            {
                Pattern = groupingDefinition.NamingPattern,
                Strategy = groupingDefinition.Strategy
            }, limitsInDisplayUnit));
        }
Exemplo n.º 3
0
        protected override void Context()
        {
            _populationDataCollector = A.Fake <IPopulationDataCollector>();
            _populationAnalysis      = A.Fake <PopulationAnalysis>();
            A.CallTo(() => _populationDataCollector.NumberOfItems).Returns(100);
            _numericField = A.Fake <PopulationAnalysisNumericField>();

            A.CallTo(() => _populationAnalysis.FieldByName(_fieldName)).Returns(_numericField);
            _fixedLimitsGroupingDefinition = new FixedLimitsGroupingDefinition(_fieldName);
            _fixedLimitsGroupingDefinition.AddItems(PopulationAnalysisHelperForSpecs.AgeGroups);
            _fixedLimitsGroupingDefinition.SetLimits((new[] { 14D, 18D }).OrderBy(x => x));

            _dt = createData();
            A.CallTo(() => _numericField.GetValues(_populationDataCollector)).Returns(_dt.AllValuesInColumn <double>(_fieldName).ToList());
            sut = new PopulationAnalysisGroupingField(_fixedLimitsGroupingDefinition)
            {
                Name = _sutName
            };
        }