public PopulationAnalysisGroupingField CreateGroupingField(GroupingDefinition groupingDefinition, IPopulationAnalysisField populationAnalysisField)
        {
            var interval     = groupingDefinition as IntervalGroupingDefinition;
            var numericField = populationAnalysisField as INumericValueField;

            updateDimension(numericField, interval);
            return(new PopulationAnalysisGroupingField(groupingDefinition));
        }
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_groupingField);

            _newGroupingDefinition = A.Fake <GroupingDefinition>();
            A.CallTo(() => _groupingDefinitionMapper.MapToModel(_snapshot.GroupingDefinition, A <SnapshotContext> ._)).Returns(_newGroupingDefinition);
        }
        /// <summary>
        ///    This method compares the given values using the ordering of the labels.
        /// </summary>
        /// <remarks>
        ///    The user has specified a list of string representations for grouping continous data
        ///    and therefor the specified labels represent an interval of underlying data values.
        ///    The data is ordered and therefor the values of the field should be sorted by the index of the value in
        ///    the labels array.
        /// </remarks>
        /// <param name="value1">For an interval grouping definition, a label, otherwise a value</param>
        /// <param name="value2">For an interval grouping definition, a label, otherwise a value</param>
        public override int Compare(object value1, object value2)
        {
            int compare;

            if (this.CouldCompareValuesToReference(value1, value2, out compare))
            {
                return(compare);
            }

            return(GroupingDefinition.Compare(value1, value2));
        }
 public override bool CanBeUsedFor(Type dataType)
 {
     return(GroupingDefinition.CanBeUsedFor(dataType));
 }
        protected override Task Context()
        {
            _groupingDefinitionMapper = A.Fake <GroupingDefinitionMapper>();
            _dimension           = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            _mergedDimension     = DomainHelperForSpecs.TimeDimensionForSpecs();
            _unit                = _mergedDimension.Unit("h"); // this unit is defined in the merged dimension but not in the field dimension
            _dimensionRepository = A.Fake <IDimensionRepository>();

            sut = new PopulationAnalysisFieldMapper(_groupingDefinitionMapper, _dimensionRepository);

            _groupingItem1 = new GroupingItem();

            _parameterField = new PopulationAnalysisParameterField
            {
                Name          = "P",
                ParameterPath = "A|B",
                Scaling       = Scalings.Linear,
                Dimension     = _dimension,
                DisplayUnit   = _unit
            };

            _pkParameterField = new PopulationAnalysisPKParameterField
            {
                Name         = "PK",
                Dimension    = _dimension,
                DisplayUnit  = _unit,
                PKParameter  = "AUC",
                QuantityPath = "A|B|C",
                QuantityType = QuantityType.Observer | QuantityType.Drug
            };

            _outputField = new PopulationAnalysisOutputField
            {
                Name         = "Output",
                Dimension    = _dimension,
                DisplayUnit  = _unit,
                QuantityType = QuantityType.BaseGrid,
                QuantityPath = "A|B|C",
                Color        = Color.AntiqueWhite
            };

            _groupingDefinition = new FixedLimitsGroupingDefinition("AA");
            _groupingField      = new PopulationAnalysisGroupingField(_groupingDefinition)
            {
                Name = "Grouping",
            };


            _covariateField = new PopulationAnalysisCovariateField
            {
                Name      = "Gender",
                Covariate = "Gender",
            };
            _covariateField.AddGroupingItem(_groupingItem1);

            _snapshotGroupingDefinition = new Snapshots.GroupingDefinition();
            A.CallTo(() => _groupingDefinitionMapper.MapToSnapshot(_groupingDefinition)).Returns(_snapshotGroupingDefinition);

            A.CallTo(() => _dimensionRepository.DimensionByName(_dimension.Name)).Returns(_dimension);
            A.CallTo(() => _dimensionRepository.MergedDimensionFor(A <INumericValueField> ._)).Returns(_mergedDimension);
            return(_completed);
        }
 public PopulationAnalysisGroupingField(GroupingDefinition groupingDefinition) : base(typeof(string))
 {
     GroupingDefinition = groupingDefinition;
 }