protected override void Context()
        {
            base.Context();
            _dp = CreateObject <DistributedParameter>().WithName("Diana").WithDimension(DimensionLength);
            ConstantFormula dpMeanFormula       = CreateObject <ConstantFormula>().WithValue(3.0);
            IParameter      dpMean              = CreateObject <Parameter>().WithName("Mean").WithFormula(dpMeanFormula);
            ConstantFormula dpDeviationFormula  = CreateObject <ConstantFormula>().WithValue(1.0);
            IParameter      dpDeviation         = CreateObject <Parameter>().WithName("Deviation").WithFormula(dpDeviationFormula);
            ConstantFormula dpPercentileFormula = CreateObject <ConstantFormula>().WithValue(0.5);
            IParameter      dpPercentile        = CreateObject <Parameter>().WithName("Percentile").WithFormula(dpPercentileFormula);

            _dp.Add(dpMean);
            _dp.Add(dpDeviation);
            _dp.Add(dpPercentile);
            IDistributionFormula noDiFo = CreateObject <NormalDistributionFormula>().WithDimension(DimensionLength);

            noDiFo.AddObjectPath(new FormulaUsablePath(new[] { Constants.Distribution.MEAN })
            {
                Alias = Constants.Distribution.MEAN, Dimension = DimensionLength
            });
            noDiFo.AddObjectPath(new FormulaUsablePath(new[] { Constants.Distribution.DEVIATION })
            {
                Alias = Constants.Distribution.DEVIATION, Dimension = DimensionLength
            });
            noDiFo.AddObjectPath(new FormulaUsablePath(new[] { Constants.Distribution.PERCENTILE })
            {
                Alias = Constants.Distribution.PERCENTILE, Dimension = DimensionLength
            });
            _dp.Formula = noDiFo;
            _dp.Formula.ResolveObjectPathsFor(_dp);

            _dp.RHSFormula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);
        }
示例#2
0
 protected override void Context()
 {
     base.Context();
     _constantFormula   = new ConstantFormula(5);
     _parameter.Formula = _constantFormula;
     _parameter.Value   = 10;
 }
示例#3
0
        protected override void Context()
        {
            base.Context();
            var displayUnitRetriever = IoC.Resolve <IDisplayUnitRetriever>();
            var f1 = new ExplicitFormula("CL*conc").WithName("formula");
            var r1 = new ReactionBuilder().WithName("Reaction").WithFormula(f1);

            r1.AddEduct(new ReactionPartnerBuilder("Drug", 1));
            r1.AddEduct(new ReactionPartnerBuilder("Metab", 1));
            r1.AddModifier("Cyp");
            var concentrationDimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            var p1Formula = new ConstantFormula(2).WithDimension(concentrationDimension);
            var p11       = new Parameter().WithName("P1").WithFormula(p1Formula).WithParentContainer(r1);

            var f2 = new ExplicitFormula("CL*conc").WithName("formula");
            var r2 = new ReactionBuilder().WithName("Reaction").WithFormula(f2);

            r2.AddEduct(new ReactionPartnerBuilder("Drug", 1));
            r2.AddEduct(new ReactionPartnerBuilder("Metab", 1));
            r2.AddModifier("Cyp");
            var p12Forumla = new ConstantFormula(3).WithDimension(concentrationDimension);
            var p12        = new Parameter().WithName("P1").WithFormula(p12Forumla).WithParentContainer(r2);

            _object1 = r1;
            _object2 = r2;

            _preferredUnit = concentrationDimension.Units.ElementAt(0);
            A.CallTo(() => displayUnitRetriever.PreferredUnitFor(p1Formula, null)).Returns(_preferredUnit);
            A.CallTo(() => displayUnitRetriever.PreferredUnitFor(p12Forumla, null)).Returns(_preferredUnit);
        }
        protected override void Context()
        {
            base.Context();
            _buidingBlockWithFormulaCache = A.Fake <IBuildingBlock>();
            _parameter = new Parameter().WithDimension(A.Fake <IDimension>());
            var constantFormula = new ConstantFormula().WithDimension(_parameter.Dimension);

            A.CallTo(() => _formulaTask.CreateNewFormula <ConstantFormula>(_parameter.Dimension)).Returns(constantFormula);
        }
示例#5
0
 protected override void Context()
 {
     base.Context();
     _constantFormula      = new ConstantFormula(2).WithDimension(A.Fake <IDimension>());
     _formula              = _constantFormula;
     _usingFormula         = A.Fake <IUsingFormula>();
     _usingFormula.Formula = _formula;
     A.CallTo(() => _dimensionMapper.ConversionFactor(_formula)).Returns(15);
 }
 /// <summary>
 /// Sets a constant value into a constant value formula
 /// </summary>
 /// <param name="constantFormula">The constant formula being edited</param>
 /// <param name="newValue">The new value being applied to the formula</param>
 /// <param name="displayUnit">The new value new display unit</param>
 /// <param name="oldUnit">The old value display unit</param>
 /// <param name="buildingBlock">The building block that this formula is a member of</param>
 /// <param name="formulaOwner">The entity that owns the formula</param>
 public SetConstantFormulaValueCommand(ConstantFormula constantFormula, double newValue, Unit displayUnit, Unit oldUnit, IBuildingBlock buildingBlock, IEntity formulaOwner) : base(buildingBlock)
 {
     _constantFormula = constantFormula;
     _newValue        = newValue;
     _oldValue        = _constantFormula.Value;
     FormulaId        = _constantFormula.Id;
     ObjectType       = new ObjectTypeResolver().TypeFor(formulaOwner);
     CommandType      = AppConstants.Commands.EditCommand;
     _ownerId         = formulaOwner.Id;
     _owner           = formulaOwner;
     _displayUnit     = displayUnit;
     _oldDisplayUnit  = oldUnit;
 }
示例#7
0
        protected override void Context()
        {
            base.Context();
            _formula               = new ConstantFormula(1);
            _parameter             = new Parameter().WithName("P1");
            _parameter.Dimension   = DomainHelperForSpecs.AmountDimension;
            _parameter.DisplayUnit = _parameter.Dimension.DefaultUnit;
            _parameter.IsDefault   = false;

            A.CallTo(() => _parametersInBuildingBlockRetriever.AllFrom(_buildingBlock, A <Func <IParameter, bool> > ._)).Returns(new[] { _parameter });
            _updateCommand = new MoBiEmptyCommand();
            A.CallTo(() => _quantityTask.UpdateDefaultStateAndValueOriginFor(_parameter, _buildingBlock)).Returns(_updateCommand);
        }
        protected override void Context()
        {
            base.Context();
            var f1 = new ConstantFormula(5);
            var f2 = new ConstantFormula(10);

            _object1 = new Parameter().WithFormula(f1);
            var parameter = new Parameter().WithFormula(f2);

            _object2 = parameter;
            _comparerSettings.FormulaComparison     = FormulaComparison.Formula;
            _comparerSettings.CompareHiddenEntities = false;
        }
示例#9
0
        public ConstantFormulaBuilderDTO MapFrom(ConstantFormula constantFormula, Unit displayUnit)
        {
            var dto = Map <ConstantFormulaBuilderDTO>(constantFormula);

            dto.Dimension = constantFormula.Dimension ?? _dimensionFactory.Dimension(Constants.Dimension.DIMENSIONLESS);
            //set the kernel value after the fact (afer display unit);
            var valueDTO = new ValueEditDTO {
                Dimension = dto.Dimension, DisplayUnit = displayUnit, KernelValue = constantFormula.Value
            };

            constantFormula.Changed += o => { valueDTO.KernelValue = constantFormula.Value; };
            dto.Value = valueDTO;
            return(dto);
        }
示例#10
0
        protected override void Context()
        {
            base.Context();
            _moleculeBuildingBlock   = new MoleculeBuildingBlock();
            _createMoleculePresenter = A.Fake <ICreatePKSimMoleculePresenter>();
            _molecule = new MoleculeBuilder();
            _molecule.DefaultStartFormula = A.Fake <IFormula>();
            A.CallTo(() => _createMoleculePresenter.CreateMolecule(_moleculeBuildingBlock)).Returns(_molecule);
            A.CallTo(() => _interactionTaskContext.ApplicationController.Start <ICreatePKSimMoleculePresenter>()).Returns(_createMoleculePresenter);
            _defaultStartFormula = new ConstantFormula();
            A.CallTo(_formulaTask).WithReturnType <ConstantFormula>().Returns(_defaultStartFormula);

            A.CallTo(() => _context.AddToHistory(A <ICommand> ._))
            .Invokes(x => _command = x.GetArgument <ICommand>(0));
        }
        public void TestSerialization()
        {
            ConstantFormula x1 = CreateObject <ConstantFormula>().WithName("Fortunato").WithDimension(DimensionLength).WithValue(5.3);

            x1.AddObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P2).WithAlias("Pitter"));
            x1.ResolveObjectPathsFor(P);

            ConstantFormula x2 = SerializeAndDeserialize(x1);

            x2.ResolveObjectPathsFor(P);

            AssertForSpecs.AreEqualConstantFormula(x2, x1);
        }
 protected override void Context()
 {
     _context = A.Fake <IMoBiContext>();
     _owner   = new Parameter {
         Id = "id", Name = "Parameter"
     };
     _formula = new ConstantFormula(3.0);
     sut      = new SetConstantFormulaValueCommand(
         constantFormula: _formula,
         newValue: 4.0,
         displayUnit: DomainHelperForSpecs.AmountDimension.DefaultUnit,
         oldUnit: DomainHelperForSpecs.ConcentrationDimension.DefaultUnit,
         buildingBlock: new ParameterStartValuesBuildingBlock(),
         formulaOwner: _owner);
     A.CallTo(() => _context.Get <IEntity>("id")).Returns(_owner);
 }
        protected override void Context()
        {
            base.Context();
            _dimension       = A.Fake <IDimension>();
            _buildingBlock   = A.Fake <IBuildingBlock>();
            _parentContainer = new ReactionBuilder();
            var modalPresenter         = A.Fake <IModalPresenter>();
            var editParameterPresenter = A.Fake <IEditParameterPresenter>();

            _parameter = new Parameter();
            A.CallTo(() => _context.Context.Create <IParameter>()).Returns(_parameter);
            A.CallTo(() => _context.UserSettings.ParameterDefaultDimension).Returns("UNKNOWN");
            A.CallTo(_context.ApplicationController).WithReturnType <IModalPresenter>().Returns(modalPresenter);
            A.CallTo(() => modalPresenter.Show()).Returns(true);
            A.CallTo(() => modalPresenter.SubPresenter).Returns(editParameterPresenter);
            A.CallTo(() => _context.ApplicationController.Start <ISelectReferenceAtParameterPresenter>()).Returns(A.Fake <ISelectReferenceAtParameterPresenter>());
            A.CallTo(_dimensionFactory).WithReturnType <IDimension>().Returns(_dimension);
            _defaultConstantFormula = new ConstantFormula();
            A.CallTo(_formulaTask).WithReturnType <ConstantFormula>().Returns(_defaultConstantFormula);
        }
示例#14
0
        protected override void Context()
        {
            base.Context();
            _modalPresenter  = A.Fake <IModalPresenter>();
            _amountDimension = A.Fake <IDimension>();
            _displayUnit     = A.Fake <Unit>();
            _editMoleculeBuilderPresenter = A.Fake <IEditPresenter <IMoleculeBuilder> >();
            _moleculeBuilderBuildingBlock = new MoleculeBuildingBlock();

            A.CallTo(() => _context.Create <IMoleculeBuilder>()).Returns(new MoleculeBuilder());
            A.CallTo(() => _dimensionRetriever.MoleculeDimension).Returns(_amountDimension);
            A.CallTo(_interactionTaskContext.ApplicationController).WithReturnType <IModalPresenter>().Returns(_modalPresenter);
            A.CallTo(_interactionTaskContext).WithReturnType <Unit>().Returns(_displayUnit);
            A.CallTo(() => _modalPresenter.SubPresenter).Returns(_editMoleculeBuilderPresenter);
            A.CallTo(() => _parameterFactory.CreateConcentrationParameter(_moleculeBuilderBuildingBlock.FormulaCache)).Returns(new Parameter {
                Name = AppConstants.Parameters.CONCENTRATION
            });

            _defaultStartFormula = new ConstantFormula();
            A.CallTo(_formulaTask).WithReturnType <ConstantFormula>().Returns(_defaultStartFormula);
        }
示例#15
0
 protected override void Context()
 {
     base.Context();
     _formula = new ConstantFormula(5);
     A.CallTo(() => _dimensionMapper.ConversionFactor(_formula)).Returns(10);
 }
示例#16
0
 protected override void Because()
 {
     _result = sut.ValueFor(_parameterValueDefinition) as ConstantFormula;
 }
示例#17
0
        public IMoBiCommand SetConstantFormulaValue(ConstantFormula formula, double kernelValue, Unit newDisplayUnit, Unit oldDisplayUnit, IBuildingBlock buildingBlock, IEntity formulaOwner)
        {
            var command = new SetConstantFormulaValueCommand(formula, kernelValue, newDisplayUnit, oldDisplayUnit, buildingBlock, formulaOwner).Run(_context);

            return(withUpdatedDefaultStateAndValueOrigin(command, formula, buildingBlock));
        }
 /// <summary>
 ///    Checks to see if the constant formula equals the double StartValue
 /// </summary>
 /// <param name="startValue">The start value to check</param>
 /// <param name="targetFormula">The formula being evaluated</param>
 /// <returns>True if the formula is constant and evaluates to the same value as startValue.StartValue</returns>
 private static bool isConstantFormulaEqualToStartValue(IStartValue startValue, ConstantFormula targetFormula)
 {
     return(startValue.StartValue.HasValue && ValueComparer.AreValuesEqual(startValue.StartValue.Value, targetFormula.Calculate(null)));
 }
 public override void RestoreExecutionData(IMoBiContext context)
 {
     _constantFormula = context.Get <ConstantFormula>(FormulaId);
     _owner           = context.Get <IEntity>(_ownerId);
 }
 protected override void ClearReferences()
 {
     base.ClearReferences();
     _constantFormula = null;
     _owner           = null;
 }
 protected override void Because()
 {
     sut = new ConstantFormula(_value);
 }