protected override void Context() { base.Context(); _populationAnalyses = A.Fake <PopulationAnalysis>(); _derivedField = A.Fake <PopulationAnalysisGroupingField>(); A.CallTo(() => _populationAnalyses.FieldByName(_fieldName)).Returns(_derivedField); sut.PopulationAnalysis = _populationAnalyses; }
protected override void Context() { base.Context(); _groupingDefinition = A.Fake<IGroupingDefinition>(); _populationAnalysisGroupingField = A.Fake<PopulationAnalysisGroupingField>(); A.CallTo(() => _groupingFieldPresenter.CreateGrouping(_field, _populationDataCollector)).Returns(_groupingDefinition); A.CallTo(() => _populationAnalysisFieldFactory.CreateGroupingField(_groupingDefinition, _field)).Returns(_populationAnalysisGroupingField); A.CallTo(() => _groupingFieldPresenter.FieldName).Returns("SUPER NAME"); }
public void should_return_false_if_the_grouping_definition_has_no_fields() { _populationAnalyses = A.Fake <PopulationAnalysis>(); sut = new PopulationAnalysisGroupingField(new FixedLimitsGroupingDefinition(null)) { Name = _sutName, PopulationAnalysis = _populationAnalyses }; sut.IsDerivedTypeFor <PopulationAnalysisParameterField>().ShouldBeFalse(); }
protected override void Context() { _view = A.Fake <IEditPopulationAnalysisGroupingFieldView>(); _groupingDefinition = A.Fake <GroupingDefinition>(); _presenterMapper = A.Fake <IGroupingDefinitionToGroupingDefinitionPresenterMapper>(); _groupingField = A.Fake <PopulationAnalysisGroupingField>(); _populationDataCollector = A.Fake <IPopulationDataCollector>(); _groupingDefinitionPresenter = A.Fake <IGroupingDefinitionPresenter>(); _groupingField.PopulationAnalysis = A.Fake <PopulationAnalysis>(); _referenceField = A.Fake <IPopulationAnalysisField>(); sut = new EditPopulationAnalysisGroupingFieldPresenter(_view, _presenterMapper); A.CallTo(() => _groupingField.ReferencedFieldName).Returns("ParameterField"); A.CallTo(() => _groupingField.GroupingDefinition).Returns(_groupingDefinition); A.CallTo(() => _presenterMapper.MapFrom(_groupingDefinition)).Returns(_groupingDefinitionPresenter); A.CallTo(() => _groupingField.PopulationAnalysis.FieldByName(_groupingField.ReferencedFieldName)).Returns(_referenceField); }
protected override void Context() { base.Context(); _expectedResultForValueMappingGroupingDefinition = initExpectedResultForValueMappingGroupingDefinition(); _valueGroupingDefinition = new ValueMappingGroupingDefinition(_fieldName); _grouping1 = new GroupingItem { Label = "Label1" }; _grouping2 = new GroupingItem { Label = "Label2" }; _valueGroupingDefinition.AddValueLabel("1", _grouping1); _valueGroupingDefinition.AddValueLabel("2", _grouping2); sut = new PopulationAnalysisGroupingField(_valueGroupingDefinition) { Name = _sutName }; }
public bool Edit(PopulationAnalysisGroupingField groupingField, IPopulationDataCollector populationDataCollector) { _groupingPresenter = _groupingDefinitionPresenterMapper.MapFrom(groupingField.GroupingDefinition); _groupingPresenter.StatusChanged += (o, e) => ViewChanged(); var referenceField = groupingField.PopulationAnalysis.FieldByName(groupingField.ReferencedFieldName); _groupingPresenter.InitializeWith(referenceField, populationDataCollector); _groupingPresenter.Edit(groupingField.GroupingDefinition); View.SetGroupingView(_groupingPresenter.BaseView); View.Caption = PKSimConstants.UI.EditGroupingFor(groupingField.Name, referenceField.Name); View.Display(); if (_view.Canceled) { return(false); } _groupingPresenter.UpdateGroupingDefinition(); return(true); }
private async Task mapGroupingFieldProperties(PopulationAnalysisField snapshot, PopulationAnalysisGroupingField field) { if (field == null) { return; } snapshot.GroupingDefinition = await _groupingDefinitionMapper.MapToSnapshot(field.GroupingDefinition); }
protected override async Task Because() { _newGroupingField = await sut.MapToModel(_snapshot, new SnapshotContext()) as PopulationAnalysisGroupingField; }
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); }
private bool validateReferenceFieldInGrouping(PopulationAnalysisDataField dataField, PopulationAnalysisGroupingField groupingField) { string referencedFieldName = groupingField.ReferencedFieldName; if (!string.Equals(referencedFieldName, dataField.Name, StringComparison.OrdinalIgnoreCase)) { var shouldUseField = _dialogCreator.MessageBoxYesNo(PKSimConstants.Warning.DerivedFieldWasSavedForAnotherField(referencedFieldName, dataField.Name)); if (shouldUseField == ViewResult.No) { return(false); } } groupingField.RenameReferencedFieldTo(dataField.Name); return(true); }
protected override void Because() { _result = sut.CreateGroupingFieldFor(_field, _populationDataCollector); }
public override void GlobalContext() { base.GlobalContext(); _populationAnalysis = new PopulationPivotAnalysis(); _pkParameterField = new PopulationAnalysisPKParameterField().WithName("PKParam"); _pkParameterField.PKParameter = "AUC"; _pkParameterField.QuantityPath = "A|B|C"; _pkParameterField.QuantityType = QuantityType.Drug; _pkParameterField.Dimension = _dimensionRepository.MassConcentration; _parameterField = new PopulationAnalysisParameterField().WithName("Param"); _parameterField.ParameterPath = "A|B|C|D"; _parameterField.Dimension = _dimensionRepository.Auc; _outputField = new PopulationAnalysisOutputField().WithName("Output"); _outputField.QuantityPath = "A|B|C"; _outputField.Dimension = _dimensionRepository.Auc; _outputField.Color = Color.Aquamarine; _genderField = new PopulationAnalysisCovariateField { Covariate = "Gender" }.WithName("Gender"); var numberOfBinsGroupingDefinition = new NumberOfBinsGroupingDefinition(_parameterField.Name) { NumberOfBins = 2 }; numberOfBinsGroupingDefinition.NamingPattern = "AA"; numberOfBinsGroupingDefinition.StartColor = Color.AliceBlue; numberOfBinsGroupingDefinition.EndColor = Color.RoyalBlue; numberOfBinsGroupingDefinition.Strategy = LabelGenerationStrategies.Roman; numberOfBinsGroupingDefinition.AddItems(PopulationAnalysisHelperForSpecs.BMIGroups); _numberOfBinsDerivedField = new PopulationAnalysisGroupingField(numberOfBinsGroupingDefinition).WithName("NumberOfBins"); var fixedLimitsGroupingDefinition = new FixedLimitsGroupingDefinition(_pkParameterField.Name); fixedLimitsGroupingDefinition.AddItems(PopulationAnalysisHelperForSpecs.AgeGroups); _fixedLimitsGroupingDefinitionField = new PopulationAnalysisGroupingField(fixedLimitsGroupingDefinition) .WithName("FixedLimits"); fixedLimitsGroupingDefinition.SetLimits(new[] { 1d, 2d }.OrderBy(x => x)); _derivedFieldWithFixedExpression = new PopulationAnalysisExpressionField("A+B") .WithName("FixedExpression"); var valueMappingGroupingDefinition = new ValueMappingGroupingDefinition(_genderField.Name); valueMappingGroupingDefinition.AddValueLabel("Male", PopulationAnalysisHelperForSpecs.GroupingItemMale); valueMappingGroupingDefinition.AddValueLabel("Female", PopulationAnalysisHelperForSpecs.GroupingItemFemale); var valueMappingGroupingDefinitionField = new PopulationAnalysisGroupingField(valueMappingGroupingDefinition).WithName("ValueMapping"); _populationAnalysis.Add(_pkParameterField); _populationAnalysis.Add(_parameterField); _populationAnalysis.Add(_genderField); _populationAnalysis.Add(_numberOfBinsDerivedField); _populationAnalysis.Add(_fixedLimitsGroupingDefinitionField); _populationAnalysis.Add(_derivedFieldWithFixedExpression); _populationAnalysis.Add(valueMappingGroupingDefinitionField); _populationAnalysis.Add(_outputField); }