Esempio n. 1
0
 protected override void Context()
 {
     _fieldName               = "TOTO";
     _numericField            = A.Fake <PopulationAnalysisNumericField>().WithName(_fieldName);
     _populationDataCollector = A.Fake <IPopulationDataCollector>();
     sut = new NumberOfBinsGroupingDefinition(_fieldName);
 }
 protected override void Context()
 {
     base.Context();
     _mergedDimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
     _field           = A.Fake <PopulationAnalysisNumericField>();
     _field.Dimension = DomainHelperForSpecs.FractionDimensionForSpecs();
     A.CallTo((_dimensionRepository)).WithReturnType <IDimension>().Returns(_mergedDimension);
 }
 protected override void Context()
 {
     base.Context();
     _mergedDimension = new Dimension();
     _field           = A.Fake <PopulationAnalysisNumericField>();
     _field.Dimension = new Dimension();
     A.CallTo((_dimensionRepository)).WithReturnType <IDimension>().Returns(_mergedDimension);
 }
Esempio n. 4
0
        public void InitializeWith(IPopulationAnalysisField populationAnalysisField, IPopulationDataCollector populationDataCollector)
        {
            _numericField = populationAnalysisField as PopulationAnalysisNumericField;

            //this should never happen
            if (_numericField == null)
            {
                throw new ArgumentException(PKSimConstants.Error.GroupingCannotBeUsedWithFieldOfType(populationAnalysisField.DataType, GroupingDefinitions.FixedLimits.DisplayName));
            }

            if (!_numericField.CanBeUsedForGroupingIn(populationDataCollector))
            {
                throw new PKSimException(PKSimConstants.Error.GroupingCannotBeCreatedForField(populationAnalysisField.Name));
            }

            _groupingDefinition      = new FixedLimitsGroupingDefinition(_numericField.Name);
            _populationDataCollector = populationDataCollector;
        }
Esempio n. 5
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
            };
        }
Esempio n. 6
0
        protected override void Context()
        {
            _view           = A.Fake <IMultipleNumericFieldsView>();
            _eventPublisher = A.Fake <IEventPublisher>();
            sut             = new MultipleNumericFieldsPresenter(_view, _eventPublisher);

            _populationAnalysis = A.Fake <PopulationPivotAnalysis>();
            sut.StartAnalysis(A.Fake <IPopulationDataCollector>(), _populationAnalysis);

            _field1 = new PopulationAnalysisParameterField();
            _field2 = new PopulationAnalysisParameterField();
            _field3 = new PopulationAnalysisParameterField();

            _allAllowedFields = new List <IPopulationAnalysisField>();
            _allDataFields    = new List <IPopulationAnalysisField>();

            sut.AllowedType = _allowedType;
            A.CallTo(() => _view.BindTo(A <IEnumerable <FieldSelectionDTO> > ._))
            .Invokes(x => _fieldsDTO = x.GetArgument <IEnumerable <FieldSelectionDTO> >(0));

            A.CallTo(() => _populationAnalysis.All(_allowedType, false)).Returns(_allAllowedFields);
            A.CallTo(() => _populationAnalysis.AllFieldsOn(PivotArea.DataArea, _allowedType)).Returns(_allDataFields);
        }
Esempio n. 7
0
        public IReadOnlyList <string> GenerateLabels(IPopulationDataCollector populationDataCollector, PopulationAnalysisNumericField numericField, LabelGenerationOptions options, int numberOfLabels)
        {
            var groupingDefinition = new NumberOfBinsGroupingDefinition(numericField.Name)
            {
                NumberOfBins  = numberOfLabels,
                NamingPattern = options.Pattern,
                Strategy      = options.Strategy
            };

            groupingDefinition.CreateLimits(populationDataCollector, numericField);
            return(GenerateLabels(populationDataCollector, numericField, groupingDefinition));
        }
Esempio n. 8
0
 private double convertedValue(PopulationAnalysisNumericField numericField, double valueInBaseUnit)
 {
     return(numericField.ValueInDisplayUnit(valueInBaseUnit));
 }
Esempio n. 9
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));
        }