protected override Task Context() { _alternativeMapper = A.Fake <AlternativeMapper>(); _parameterMapper = A.Fake <ParameterMapper>(); _calculationMethodCacheMapper = A.Fake <CalculationMethodCacheMapper>(); _processMapper = A.Fake <CompoundProcessMapper>(); _compoundFactory = A.Fake <ICompoundFactory>(); sut = new CompoundMapper(_parameterMapper, _alternativeMapper, _calculationMethodCacheMapper, _processMapper, _compoundFactory); _compound = new Model.Compound { Name = "Compound", Description = "Description" }; addPkAParameters(_compound, 0, 8, CompoundType.Base); addPkAParameters(_compound, 1, 4, CompoundType.Acid); addPkAParameters(_compound, 2, 7, CompoundType.Neutral); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_LIPOPHILICITY)); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_FRACTION_UNBOUND)); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_SOLUBILITY)); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_INTESTINAL_PERMEABILITY)); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_PERMEABILITY)); _compound.Add(DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameters.IS_SMALL_MOLECULE)); _compound.Add(DomainHelperForSpecs.ConstantParameterWithValue((int)PlasmaProteinBindingPartner.Glycoprotein).WithName(CoreConstants.Parameters.PLASMA_PROTEIN_BINDING_PARTNER)); _partialProcess = new EnzymaticProcess().WithName("EnzymaticProcess"); _systemicProcess = new SystemicProcess().WithName("SystemicProcess"); _compound.AddProcess(_partialProcess); _compound.AddProcess(_systemicProcess); _calculationMethodCacheSnapshot = new CalculationMethodCache(); A.CallTo(() => _calculationMethodCacheMapper.MapToSnapshot(_compound.CalculationMethodCache)).Returns(_calculationMethodCacheSnapshot); _snapshotProcess1 = new CompoundProcess(); _snapshotProcess2 = new CompoundProcess(); A.CallTo(() => _processMapper.MapToSnapshot(_partialProcess)).Returns(_snapshotProcess1); A.CallTo(() => _processMapper.MapToSnapshot(_systemicProcess)).Returns(_snapshotProcess2); return(_completed); }
protected override Task Context() { _parameterMapper = A.Fake <ParameterMapper>(); _alternativeMapper = A.Fake <AlternativeMapper>(); _calculationMethodCacheMapper = A.Fake <CalculationMethodCacheMapper>(); _processMapper = A.Fake <CompoundProcessMapper>(); _compoundFactory = A.Fake <ICompoundFactory>(); _valueOriginMapper = A.Fake <ValueOriginMapper>(); sut = new CompoundMapper(_parameterMapper, _alternativeMapper, _calculationMethodCacheMapper, _processMapper, _valueOriginMapper, _compoundFactory); _compound = new Model.Compound { Name = "Compound", Description = "Description" }; _pkaValueOrigin = new ValueOrigin { Method = ValueOriginDeterminationMethods.InVitro, Description = "PKA" }; _snapshotValueOrigin = new Snapshots.ValueOrigin { Method = ValueOriginDeterminationMethodId.InVivo, Description = "PKA" }; addPkAParameters(_compound, 0, 8, CompoundType.Base); addPkAParameters(_compound, 1, 4, CompoundType.Acid); addPkAParameters(_compound, 2, 7, CompoundType.Neutral); _compoundIntestinalPermeabilityAlternativeGroup = createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_INTESTINAL_PERMEABILITY); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_LIPOPHILICITY)); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_FRACTION_UNBOUND)); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_SOLUBILITY)); _compound.AddParameterAlternativeGroup(createParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_PERMEABILITY)); _compound.AddParameterAlternativeGroup(_compoundIntestinalPermeabilityAlternativeGroup); _compoundIntestinalPermeabilityAlternativeGroup.DefaultAlternative.IsDefault = true; //Calculated alternative will not be the default alternative for intestinal perm _calculatedAlternative = new ParameterAlternative { Name = PKSimConstants.UI.CalculatedAlernative, IsDefault = false }; _compoundIntestinalPermeabilityAlternativeGroup.AddAlternative(_calculatedAlternative); //Mapping of a calculated alternative returns null A.CallTo(() => _alternativeMapper.MapToSnapshot(_calculatedAlternative)).Returns(Task.FromResult <Alternative>(null)); _compound.Add(DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameters.IS_SMALL_MOLECULE)); _compound.Add(DomainHelperForSpecs.ConstantParameterWithValue((int)PlasmaProteinBindingPartner.Glycoprotein).WithName(CoreConstants.Parameters.PLASMA_PROTEIN_BINDING_PARTNER)); _partialProcess = new EnzymaticProcess().WithName("EnzymaticProcess"); _systemicProcess = new SystemicProcess().WithName("SystemicProcess"); _compound.AddProcess(_partialProcess); _compound.AddProcess(_systemicProcess); _calculationMethodCacheSnapshot = new CalculationMethodCache(); A.CallTo(() => _calculationMethodCacheMapper.MapToSnapshot(_compound.CalculationMethodCache)).Returns(_calculationMethodCacheSnapshot); _snapshotProcess1 = new CompoundProcess(); _snapshotProcess2 = new CompoundProcess(); A.CallTo(() => _processMapper.MapToSnapshot(_partialProcess)).Returns(_snapshotProcess1); A.CallTo(() => _processMapper.MapToSnapshot(_systemicProcess)).Returns(_snapshotProcess2); _molweightParameter = DomainHelperForSpecs.ConstantParameterWithValue(400).WithName(Constants.Parameters.MOL_WEIGHT); _molweightParameter.ValueOrigin.Method = ValueOriginDeterminationMethods.InVivo; //Do not update F value origin to ensure that it's being synchronized when mapping from snapshot _halogenFParameter = DomainHelperForSpecs.ConstantParameterWithValue(5).WithName(Constants.Parameters.F); _compound.Add(_molweightParameter); _compound.Add(_halogenFParameter); return(_completed); }
protected override Task Context() { _calculationMethodCacheMapper = A.Fake <CalculationMethodCacheMapper>(); _processMappingMapper = A.Fake <ProcessMappingMapper>(); _logger = A.Fake <ILogger>(); _project = new PKSimProject(); _calculationMethodSnapshot = new CalculationMethodCache(); sut = new CompoundPropertiesMapper(_calculationMethodCacheMapper, _processMappingMapper, _logger); _compoundGroupSelectionOneAlternative = new CompoundGroupSelection { AlternativeName = "ALT1", GroupName = "ALTERNATIVE_GROUP_1" }; _compoundGroupSelectionTwoAlternatives = new CompoundGroupSelection { AlternativeName = "ALT2", GroupName = "ALTERNATIVE_GROUP_2" }; _compound = new Compound { Name = "COMP", }; _protocol = new SimpleProtocol { Name = "PROTOCOL" }; _parameterAlternativeGroupWithOneAlternative = new ParameterAlternativeGroup { Name = _compoundGroupSelectionOneAlternative.GroupName }; _parameterAlternativeGroupWithTwoAlternatives = new ParameterAlternativeGroup { Name = _compoundGroupSelectionTwoAlternatives.GroupName }; _parameterAlternativeGroupWithTwoAlternatives.AddAlternative(new ParameterAlternative { Name = "ALT1" }); _parameterAlternativeGroupWithTwoAlternatives.AddAlternative(new ParameterAlternative { Name = "ALT2" }); _compound.AddParameterAlternativeGroup(_parameterAlternativeGroupWithOneAlternative); _compound.AddParameterAlternativeGroup(_parameterAlternativeGroupWithTwoAlternatives); _compoundProperties = new Model.CompoundProperties(); _compoundProperties.AddCompoundGroupSelection(_compoundGroupSelectionOneAlternative); _compoundProperties.AddCompoundGroupSelection(_compoundGroupSelectionTwoAlternatives); _compoundProperties.Compound = _compound; _enzymaticProcess = new EnzymaticProcess { Name = "EnzymaticProcess" }; _anotherEnzymaticProcess = new EnzymaticProcess { Name = "AnotherEnzymaticProcess", MoleculeName = "CYP3A4" }; _specificBindingProcess = new SpecificBindingPartialProcess { Name = "SpecificBinding" }; _gfrTransportProcess = new SystemicProcess { Name = "Transport", SystemicProcessType = SystemicProcessTypes.GFR }; _hepaticEnzymaticProcess = new SystemicProcess { Name = "Plasma Clearance", SystemicProcessType = SystemicProcessTypes.Hepatic }; _compound.AddProcess(_enzymaticProcess); _compound.AddProcess(_specificBindingProcess); _compound.AddProcess(_gfrTransportProcess); _compound.AddProcess(_hepaticEnzymaticProcess); _enzymaticPartialProcessSelection = new EnzymaticProcessSelection { ProcessName = _enzymaticProcess.Name }; _noEnzymaticSystemicProcessSelection = new SystemicProcessSelection { ProcessType = SystemicProcessTypes.Hepatic }; _specificBindingPartialProcessSelection = new ProcessSelection { ProcessName = _specificBindingProcess.Name }; _transportSystemicProcessSelection = new SystemicProcessSelection { ProcessName = _gfrTransportProcess.Name, ProcessType = _gfrTransportProcess.SystemicProcessType, }; _noEnzymaticPartialProcessSelection = new EnzymaticProcessSelection { MoleculeName = _anotherEnzymaticProcess.MoleculeName }; _compoundProperties.Processes.MetabolizationSelection.AddPartialProcessSelection(_enzymaticPartialProcessSelection); _compoundProperties.Processes.MetabolizationSelection.AddPartialProcessSelection(_noEnzymaticPartialProcessSelection); _compoundProperties.Processes.MetabolizationSelection.AddSystemicProcessSelection(_noEnzymaticSystemicProcessSelection); _compoundProperties.Processes.SpecificBindingSelection.AddPartialProcessSelection(_specificBindingPartialProcessSelection); _compoundProperties.Processes.TransportAndExcretionSelection.AddSystemicProcessSelection(_transportSystemicProcessSelection); _snapshotProcess1 = new CompoundProcessSelection { Name = _enzymaticPartialProcessSelection.ProcessName }; _snapshotProcess2 = new CompoundProcessSelection { Name = _specificBindingPartialProcessSelection.ProcessName }; _snapshotProcess3 = new CompoundProcessSelection { Name = _transportSystemicProcessSelection.ProcessName }; _snapshotProcess4 = new CompoundProcessSelection { SystemicProcessType = _noEnzymaticSystemicProcessSelection.ProcessType.SystemicProcessTypeId.ToString() }; _snapshotProcess5 = new CompoundProcessSelection { MoleculeName = _noEnzymaticPartialProcessSelection.MoleculeName }; _formulation = new Formulation { Id = "123456" }; _compoundProperties.ProtocolProperties.Protocol = _protocol; _compoundProperties.ProtocolProperties.AddFormulationMapping(new FormulationMapping { FormulationKey = "F1", TemplateFormulationId = _formulation.Id }); _project.AddBuildingBlock(_formulation); A.CallTo(() => _calculationMethodCacheMapper.MapToSnapshot(_compoundProperties.CalculationMethodCache)).Returns(_calculationMethodSnapshot); A.CallTo(() => _processMappingMapper.MapToSnapshot(_enzymaticPartialProcessSelection)).Returns(_snapshotProcess1); A.CallTo(() => _processMappingMapper.MapToSnapshot(_specificBindingPartialProcessSelection)).Returns(_snapshotProcess2); A.CallTo(() => _processMappingMapper.MapToSnapshot(_transportSystemicProcessSelection)).Returns(_snapshotProcess3); A.CallTo(() => _processMappingMapper.MapToSnapshot(_noEnzymaticSystemicProcessSelection)).Returns(_snapshotProcess4); A.CallTo(() => _processMappingMapper.MapToSnapshot(_noEnzymaticPartialProcessSelection)).Returns(_snapshotProcess5); A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess1, _enzymaticProcess)).Returns(_enzymaticPartialProcessSelection); A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess2, _specificBindingProcess)).Returns(_specificBindingPartialProcessSelection); A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess3, _gfrTransportProcess)).Returns(_transportSystemicProcessSelection); A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess4, A <NotSelectedSystemicProcess> ._)).Returns(_noEnzymaticSystemicProcessSelection); A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess5, A <EnzymaticProcess> ._)).Returns(_noEnzymaticPartialProcessSelection); return(_completed); }