protected override void Context() { _valueToSet = 20; _oldValue = 30; _unit = A.Fake <Unit>(); A.CallTo(() => _unit.Name).Returns("_unit"); _dimension = A.Fake <IDimension>(); var container = new Container(); var objectPathFactory = new ObjectPathFactoryForSpecs(); var p1 = DomainHelperForSpecs.ConstantParameterWithValue(10).WithName("P1"); container.Add(p1); _parameter = new PKSimParameter().WithFormula(new ExplicitFormula(_oldValue.ToString())) .WithId("tralala") .WithDimension(_dimension); container.Add(_parameter); _parameter.Formula.AddObjectPath(objectPathFactory.CreateRelativeFormulaUsablePath(_parameter, p1)); A.CallTo(() => _dimension.Unit(_unit.Name)).Returns(_unit); _parameter.DisplayUnit = _unit; _executionContext = A.Fake <IExecutionContext>(); A.CallTo(() => _executionContext.Get <IParameter>(_parameter.Id)).Returns(_parameter); A.CallTo(() => _executionContext.BuildingBlockContaining(_parameter)).Returns(A.Fake <IPKSimBuildingBlock>()); sut = new SetParameterValueCommand(_parameter, _valueToSet); }
public static IDistributedParameter NormalDistributedParameter(double defaultMean = 0, double defaultDeviation = 1, double defaultPercentile = 0.5) { var parameter = new PKSimDistributedParameter().WithId("P1"); var pathFactory = new ObjectPathFactoryForSpecs(); var meanParameter = new PKSimParameter { Name = Constants.Distribution.MEAN }.WithFormula(new ConstantFormula(defaultMean).WithId("MeanFormula")).WithId("Mean"); addDimensionTo(meanParameter); var stdParameter = new PKSimParameter { Name = Constants.Distribution.DEVIATION }.WithFormula(new ConstantFormula(defaultDeviation).WithId("DeviationFormula")).WithId("Deviation"); addDimensionTo(stdParameter); var percentileParameter = new PKSimParameter { Name = Constants.Distribution.PERCENTILE }.WithFormula(new ConstantFormula(defaultPercentile).WithId("PercentileFormula")).WithId("Percentile"); addDimensionTo(percentileParameter); parameter.Add(meanParameter); parameter.Add(stdParameter); parameter.Add(percentileParameter); parameter.Formula = new NormalDistributionFormula().WithId("NormalDistributionFormula"); parameter.Formula.AddObjectPath(pathFactory.CreateRelativeFormulaUsablePath(parameter, meanParameter)); parameter.Formula.AddObjectPath(pathFactory.CreateRelativeFormulaUsablePath(parameter, stdParameter)); addDimensionTo(parameter); return(parameter); }
protected override void Context() { base.Context(); _executionContext = A.Fake <IExecutionContext>(); var container = new Container(); var objectPathFactory = new ObjectPathFactoryForSpecs(); _paraWithValueUnchanged1 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("para1").WithDimension(A.Fake <IDimension>()); _paraWithValueUnchanged1.IsFixedValue = false; _paraWithValueChanged2 = DomainHelperForSpecs.ConstantParameterWithValue(2).WithName("para2").WithDimension(A.Fake <IDimension>()); _paraWithValueChanged2.Id = "tralala"; _paraWithValueChanged2.Formula = new ExplicitFormula("15"); _paraWithValueChanged2.Formula.AddObjectPath(objectPathFactory.CreateRelativeFormulaUsablePath(_paraWithValueChanged2, _paraWithValueUnchanged1)); _paraWithValueChanged2.Value = 20; _paraWithValueUnchanged3 = DomainHelperForSpecs.ConstantParameterWithValue(3).WithName("para3"); _distributedParameter = DomainHelperForSpecs.NormalDistributedParameter().WithName("para4"); _distributedParameter.Value = 1.2; _distributedParameter.IsFixedValue = false; _paraWithValueUnchanged3.IsFixedValue = false; container.Add(_paraWithValueChanged2); container.Add(_paraWithValueUnchanged1); container.Add(_paraWithValueUnchanged3); container.Add(_distributedParameter); _parameterToReset.Add(_paraWithValueUnchanged1); _parameterToReset.Add(_paraWithValueChanged2); _parameterToReset.Add(_paraWithValueUnchanged3); _parameterToReset.Add(_distributedParameter); A.CallTo(() => _executionContext.BuildingBlockContaining(_paraWithValueChanged2)).Returns(A.Fake <IPKSimBuildingBlock>()); }
protected override void Context() { _simulation = A.Fake <Simulation>(); _competitiveInhibition = new InhibitionProcess { InteractionType = InteractionType.CompetitiveInhibition }.WithName("CompetitiveInhibition"); _nonCompetitiveInhibition1 = new InhibitionProcess { InteractionType = InteractionType.NonCompetitiveInhibition }.WithName("NonCompetitiveInhibition1"); _nonCompetitiveInhibition2 = new InhibitionProcess { InteractionType = InteractionType.NonCompetitiveInhibition }.WithName("NonCompetitiveInhibition2"); _compound1 = new Compound().WithName("Compound1"); _compound1.AddProcess(_competitiveInhibition); _interactionTask = new InteractionTask(); _compound2 = new Compound().WithName("Compound2"); _compound2.AddProcess(_nonCompetitiveInhibition1); _compound2.AddProcess(_nonCompetitiveInhibition2); _interactionProperties = new InteractionProperties(); A.CallTo(() => _simulation.InteractionProperties).Returns(_interactionProperties); A.CallTo(() => _simulation.Compounds).Returns(new[] { _compound1, _compound2 }); _objectPathFactory = new ObjectPathFactoryForSpecs(); _dimensionRepository = A.Fake <IDimensionRepository>(); _interactionProperties.AddInteraction(new InteractionSelection { MoleculeName = _moleculeName, ProcessName = _competitiveInhibition.Name, CompoundName = _compound1.Name }); _interactionProperties.AddInteraction(new InteractionSelection { MoleculeName = _moleculeName, ProcessName = _nonCompetitiveInhibition1.Name, CompoundName = _compound2.Name }); _interactionProperties.AddInteraction(new InteractionSelection { MoleculeName = _moleculeName, ProcessName = _nonCompetitiveInhibition2.Name, CompoundName = _compound2.Name }); _dimensionRepository = A.Fake <IDimensionRepository>(); _objectPathFactory = new ObjectPathFactoryForSpecs(); sut = new NonCompetitiveInhibitionKineticUpdaterSpecification(_objectPathFactory, _dimensionRepository, _interactionTask); }
protected override void Context() { sut = new ExpressionContainersRetriever(); var objectPathFactory = new ObjectPathFactoryForSpecs(); var entityPathResolver = new EntityPathResolverForSpecs(); _liver.Add(_intLiver); _liver.Add(_cellLiver); _liver.Add(_plsLiver); _liver.Add(_bcLiver); _liver.Add(_endoLiver); _kidney.Add(_intKidney); _kidney.Add(_cellKidney); _kidney.Add(_plsKidney); _kidney.Add(_bcKidney); _kidney.Add(_endoKidney); _lumen.Add(_duodenum); _organism.Add(_liver); _organism.Add(_kidney); _organism.Add(_lumen); _protein = new IndividualEnzyme(); _protein.Add(new MoleculeExpressionContainer { OrganPath = objectPathFactory.CreateObjectPathFrom(CoreConstants.Compartment.BloodCells) }.WithName(CoreConstants.Compartment.BloodCells)); _protein.Add(new MoleculeExpressionContainer { OrganPath = objectPathFactory.CreateObjectPathFrom(CoreConstants.Compartment.Plasma) }.WithName(CoreConstants.Compartment.Plasma)); _protein.Add(new MoleculeExpressionContainer { OrganPath = objectPathFactory.CreateObjectPathFrom(CoreConstants.Compartment.VascularEndothelium) }.WithName(CoreConstants.Compartment.VascularEndothelium)); _protein.Add(new MoleculeExpressionContainer { OrganPath = entityPathResolver.ObjectPathFor(_liver) }.WithName(CoreConstants.Organ.Liver)); _protein.Add(new MoleculeExpressionContainer { OrganPath = entityPathResolver.ObjectPathFor(_kidney) }.WithName(CoreConstants.Organ.Kidney)); _protein.Add(new MoleculeExpressionContainer { OrganPath = entityPathResolver.ObjectPathFor(_lumen), GroupName = CoreConstants.Groups.GI_LUMEN, ContainerName = _duodenum.Name }.WithName(CoreConstants.ContainerName.LumenSegmentNameFor("Duodenum"))); }
protected override void Context() { _executionContext = A.Fake <IExecutionContext>(); _dimension = A.Fake <IDimension>(); _originValue = 10; var container = new Container(); var oneParameter = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("P1"); var objectPathFactory = new ObjectPathFactoryForSpecs(); _parameterToReset = DomainHelperForSpecs.ConstantParameterWithValue(_originValue).WithId("tralala").WithDimension(_dimension); _parameterToReset.Formula = new ExplicitFormula("10"); container.Add(oneParameter); container.Add(_parameterToReset); _parameterToReset.Formula.AddObjectPath(objectPathFactory.CreateRelativeFormulaUsablePath(_parameterToReset, oneParameter)); A.CallTo(() => _executionContext.Get <IParameter>(_parameterToReset.Id)).Returns(_parameterToReset); A.CallTo(() => _executionContext.BuildingBlockContaining(_parameterToReset)).Returns(A.Fake <IPKSimBuildingBlock>()); sut = new ResetParameterCommand(_parameterToReset); }
protected override void Context() { _originValue = 15; var container = new Container(); var otherParameter = DomainHelperForSpecs.ConstantParameterWithValue(10).WithName("P"); var objectPathFactory = new ObjectPathFactoryForSpecs(); sut = new PKSimParameter().WithName("toto"); container.Add(otherParameter); container.Add(sut); sut.Formula = new ExplicitFormula(_originValue.ToString(new NumberFormatInfo())); sut.Formula.AddObjectPath(objectPathFactory.CreateRelativeFormulaUsablePath(sut, otherParameter)); sut.PropertyChanged += (o, e) => { if (e.PropertyName.Equals("Value")) { _valueChangedEventRaised = true; } }; }