protected override void Context()
        {
            sut = new TableFormulaWithXArgument();

            _dimensionLength = new Dimension(new BaseDimensionRepresentation {
                LengthExponent = 1
            }, "Length", "m");
            _dimensionLength.AddUnit("cm", 0.01, 0);
            _dimensionpH = new Dimension(new BaseDimensionRepresentation(), "pH", "");

            _tableFormula = new TableFormula().WithName(_tableObjectAlias);
            _tableFormula.AddPoint(1, 10);
            _tableFormula.AddPoint(2, 20);
            _tableFormula.AddPoint(3, 30);

            _tableObject         = new Parameter().WithName(_tableObjectAlias);
            _tableObject.Formula = _tableFormula;
            _xArgumentObject     = new Parameter().WithName(_xArgumentObjectAlias).WithValue(5);

            _parameter = new Parameter().WithFormula(sut);

            _container = new Container {
                _tableObject, _xArgumentObject, _parameter
            };

            var tableObjectPath = new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, _tableObjectAlias).WithAlias(_tableObjectAlias);

            sut.AddTableObjectPath(tableObjectPath);
            var xArgumentObjectPath = new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, _xArgumentObjectAlias).WithAlias(_xArgumentObjectAlias);

            sut.AddXArgumentObjectPath(xArgumentObjectPath);
        }
        protected override void Context()
        {
            base.Context();
            _commandCollector  = A.Fake <ICommandCollector>();
            _formula           = new ExplicitFormula();
            _formulaUsablePath = new FormulaUsablePath("path")
            {
                Alias = "alias", Dimension = DimensionFactoryForSpecs.MassDimension
            };
            _formula.AddObjectPath(_formulaUsablePath);

            var formulaUsablePath = new FormulaUsablePath("path")
            {
                Alias = "alias"
            };

            _formulaUsablePathDTO = new FormulaUsablePathDTO(formulaUsablePath, _formula);
            _dto = new ExplicitFormulaBuilderDTO {
                ObjectPaths = new List <FormulaUsablePathDTO> {
                    _formulaUsablePathDTO
                }
            };
            A.CallTo(() => _explicitFormulaMapper.MapFrom(_formula, A <IUsingFormula> ._)).Returns(_dto);
            sut.Edit(_formula);
            sut.InitializeWith(_commandCollector);

            A.CallTo(() => _moBiFormulaTask.AddFormulaUsablePath(_formula, A <IFormulaUsablePath> ._, A <IBuildingBlock> ._))
            .Invokes(x => _newFormulaPath = x.GetArgument <IFormulaUsablePath>(1));
        }
 protected override void Context()
 {
     base.Context();
     _newAlias                     = "new_Name";
     _changedObject.Name           = "Name really old";
     _changedName                  = _changedObject.Name;
     _oldAlias                     = "Name_really_old";
     _theFormula                   = new ExplicitFormula(String.Format("k_{0}*{0}", _oldAlias));
     _formulaUsablePathNotToChange = new FormulaUsablePath(new[] { ObjectPath.PARENT_CONTAINER, "BLA", String.Format("k_{0}", _oldAlias) })
     {
         Alias = String.Format("k_{0}", _oldAlias)
     };
     _theFormula.AddObjectPath(_formulaUsablePathNotToChange);
     _formulaUsablePathToChange = new FormulaUsablePath(new[] { ObjectPath.PARENT_CONTAINER, _changedName })
     {
         Alias = _oldAlias
     };
     _theFormula.AddObjectPath(_formulaUsablePathToChange);
     _theFormula.Name = "F1";
     A.CallTo(() => _aliasCreator.CreateAliasFrom(_changedName)).Returns(_oldAlias);
     A.CallTo(() => _aliasCreator.CreateAliasFrom(_newName)).Returns(_newAlias);
     A.CallTo(() => _context.Get <IObjectBase>(A <string> ._)).Returns(_theFormula);
     _moleculeBuildingBlock = new MoleculeBuildingBlock().WithName("M").WithId("M");
     _moleculeBuildingBlock.AddFormula(_theFormula);
 }
        protected override void Context()
        {
            sut = new TableFormulaWithOffset();

            _dimensionLength = new Dimension(new BaseDimensionRepresentation {
                LengthExponent = 1
            }, "Length", "m");
            _dimensionLength.AddUnit("cm", 0.01, 0);
            _dimensionpH = new Dimension(new BaseDimensionRepresentation(), "pH", "");

            _tableFormula = new TableFormula().WithName(_tableObjectAlias);
            _tableFormula.AddPoint(1, 10);
            _tableFormula.AddPoint(2, 20);
            _tableFormula.AddPoint(3, 30);

            _tableObject         = new Parameter().WithName(_tableObjectAlias);
            _tableObject.Formula = _tableFormula;
            _offsetObject        = new Parameter().WithName(_offsetObjectAlias).WithValue(5);

            _dependentObject = new MoleculeAmount {
                _tableObject, _offsetObject
            };

            var tableObjectPath = new FormulaUsablePath(_tableObjectAlias).WithAlias(_tableObjectAlias);

            sut.AddTableObjectPath(tableObjectPath);
            var offsetObjectPath = new FormulaUsablePath(_offsetObjectAlias).WithAlias(_offsetObjectAlias);

            sut.AddOffsetObjectPath(offsetObjectPath);
        }
        public void TestSerialization()
        {
            EventBuilder x1 = CreateObject <EventBuilder>().WithName("Eve.Builder").WithDimension(DimensionLength);

            x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);
            x1.OneTime = true;

            IFormula           f1  = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty");
            IFormulaUsablePath fup = new FormulaUsablePath(new string[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength);

            f1.AddObjectPath(fup);
            IFormula f2 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);

            IParameter p1 = WithExtensions.WithValue <Parameter>(CreateObject <Parameter>().WithName("Patricia").WithFormula(f1), 3.1);
            IParameter p2 = WithExtensions.WithValue <Parameter>(CreateObject <Parameter>().WithName("Pascal").WithFormula(f1), 3.2);

            x1.AddParameter(p1);
            x1.AddParameter(p2);

            IEventAssignmentBuilder eab1 = CreateObject <EventAssignmentBuilder>().WithDimension(DimensionLength).WithFormula(f1).WithName("eab1");
            IEventAssignmentBuilder eab2 = CreateObject <EventAssignmentBuilder>().WithFormula(f2).WithName("eab2");

            x1.AddAssignment(eab1);
            x1.AddAssignment(eab2);

            var x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualEventBuilder(x1, x2);
        }
예제 #6
0
 protected override void Context()
 {
     base.Context();
     _formula = new ExplicitFormula {
         Id = "id"
     };
     _formulaUsablePath = new FormulaUsablePath("A", "B").WithAlias("OLD");
     _formula.AddObjectPath(_formulaUsablePath);
     A.CallTo(() => _context.Get <IFormula>(_formula.Id)).Returns(_formula);
 }
        protected override void Context()
        {
            base.Context();
            _objPathMolecule   = new FormulaUsablePath(new[] { ObjectPathKeywords.MOLECULE });
            _moleculeName      = "REPLACED";
            _moleculeContainer = new Container().WithName(_modelName);
            var moleculeParameter = new Parameter().WithFormula(A.Fake <IFormula>());

            _moleculeContainer.Add(moleculeParameter);
            A.CallTo(() => moleculeParameter.Formula.ObjectPaths).Returns(new[] { _objPathFirstNeighbor, _objPathMolecule, _objPathOrganism });
        }
예제 #8
0
        protected override void Context()
        {
            base.Context();
            var invalidPath = new FormulaUsablePath("")
            {
                Alias = "invalaid"
            };

            _formula.AddObjectPath(invalidPath);
            sut = new FormulaUsablePathDTO(invalidPath, _formula);
        }
        public void TestSerialization()
        {
            MoleculeBuilder x1 = CreateObject <MoleculeBuilder>().WithName("Monica.Builder");

            x1.IsFloating          = true;
            x1.QuantityType        = QuantityType.Metabolite;
            x1.DefaultStartFormula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);
            TransportBuilder t1                   = CreateObject <TransportBuilder>().WithName("Passive Transport");
            IFormula         consFormula          = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(5);
            IParameter       transporterParameter = CreateObject <Parameter>().WithName("Passive Transport Param").WithFormula(consFormula).WithMode(ParameterBuildMode.Property)
                                                    .WithDimension(DimensionLength);

            t1.AddParameter(transporterParameter);
            IFormula           f1  = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty");
            IFormulaUsablePath fup = new FormulaUsablePath(new[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength);

            f1.AddObjectPath(fup);
            IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithValue(3.1).WithMode(ParameterBuildMode.Property);
            IParameter p2 = CreateObject <Parameter>().WithName("Pascal").WithFormula(f1).WithValue(3.2).WithMode(ParameterBuildMode.Local);
            IParameter p3 = CreateObject <Parameter>().WithName("Paul").WithFormula(f1).WithValue(3.3);

            x1.AddParameter(p1);
            x1.AddParameter(p2);

            var atbc1 = CreateObject <TransporterMoleculeContainer>().WithName("Tranquilo");
            ITransportBuilder atb1 = CreateObject <TransportBuilder>();

            atb1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(2.5);
            atb1.AddParameter(p3);
            atb1.Name = "Tranquilo";
            atbc1.AddActiveTransportRealization(atb1);
            var atbc2 = CreateObject <TransporterMoleculeContainer>().WithName("Tranquilo2");
            ITransportBuilder atb2 = CreateObject <TransportBuilder>();

            atb2.Formula = f1;
            atb2.Name    = "Tranquilo2";
            atbc2.AddActiveTransportRealization(atb2);
            x1.AddTransporterMoleculeContainer(atbc1);
            x1.AddTransporterMoleculeContainer(atbc2);
            x1.IsXenobiotic = !x1.IsXenobiotic;


            var interactionContainer = CreateObject <InteractionContainer>().WithName("Interactions");

            x1.AddInteractionContainer(interactionContainer);

            var x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualMoleculeBuilder(x1, x2);
        }
        public void TestSerialization()
        {
            IFormula           f1  = CreateObject <ConstantFormula>().WithName("F.Constantin").WithDimension(DimensionLength).WithValue(2.1);
            IFormula           f2  = CreateObject <ExplicitFormula>().WithName("F.Erika").WithDimension(DimensionLength).WithFormulaString("A * 2");
            IFormulaUsablePath fup = new FormulaUsablePath(new[] { "aa", "bb" }).WithAlias("b").WithDimension(DimensionLength);

            f2.AddObjectPath(fup);

            FormulaCache x1 = new FormulaCache();

            x1.Add(f1);
            x1.Add(f2);

            IFormulaCache x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualFormulaCache(x2, x1);
        }
예제 #11
0
        public void TestSerializationParameterBuilderWithParameterWithExplicitFormula()
        {
            IFormula  f1 = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty");
            Parameter x1 = CreateObject <Parameter>().WithName("Peter").WithFormula(f1);

            x1.BuildMode = ParameterBuildMode.Local;

            IFormulaUsablePath fup = new FormulaUsablePath(new[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength);

            f1.AddObjectPath(fup);

            x1.Value = 3.4;


            IParameter x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualParameterBuilder(x2, x1);
        }
예제 #12
0
        protected override void Context()
        {
            base.Context();
            _equalFormula1 = new TableFormulaWithOffset().WithName("Equal");
            _equalFormula2 = new TableFormulaWithOffset().WithName("Equal");
            var offsetObjectPath = new FormulaUsablePath(new[] { "X" }).WithAlias("Offset");

            _equalFormula1.AddOffsetObjectPath(offsetObjectPath);
            _equalFormula2.AddOffsetObjectPath(offsetObjectPath);
            var tableObjectPath = new FormulaUsablePath(new[] { "Y" }).WithAlias("Table");

            _equalFormula1.AddTableObjectPath(tableObjectPath);
            _equalFormula2.AddTableObjectPath(tableObjectPath);

            _unequalFormula = new TableFormulaWithOffset().WithName("Equal");
            _unequalFormula.AddOffsetObjectPath(new FormulaUsablePath(new[] { "A" }).WithAlias("Offset"));
            _unequalFormula.AddTableObjectPath(new FormulaUsablePath(new[] { "B" }).WithAlias("Table"));
        }
        public void TestSimpleBB()
        {
            var x1 = CreateObject <ObserverBuildingBlock>().WithName("Bob");

            x1.Creation.Origin       = Origins.MoBi;
            x1.Creation.CreationMode = CreationMode.Configure;
            x1.Creation.ClonedFrom   = "Sim";

            var f1  = CreateObject <ConstantFormula>().WithName("F.Constantin").WithDimension(DimensionLength).WithValue(2.1);
            var f2  = CreateObject <ConstantFormula>().WithName("F.Constanze").WithDimension(DimensionLength).WithValue(5.6);
            var f3  = CreateObject <ExplicitFormula>().WithName("F.Erika").WithDimension(DimensionLength).WithFormulaString("A * 2");
            var fup = new FormulaUsablePath(new[] { "aa", "bb" }).WithAlias("b").WithDimension(DimensionLength);

            f3.AddObjectPath(fup);

            x1.AddFormula(f1);
            x1.AddFormula(f2);
            x1.AddFormula(f3);

            var builder = CreateObject <AmountObserverBuilder>();

            builder.MoleculeList.ForAll = false;
            builder.AddMoleculeName("H2O");
            builder.AddMoleculeName("CO2");
            builder.ContainerCriteria = new DescriptorCriteria
            {
                new MatchTagCondition("Organ"),
                new NotMatchTagCondition("Organ")
            };
            builder.Formula = f3;

            var builder2 = CreateObject <ContainerObserverBuilder>();

            builder2.ForAll  = true;
            builder2.Formula = f2;

            x1.Add(builder);
            x1.Add(builder2);

            var x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualBuildingBlock(x2, x1);
        }
예제 #14
0
        public void TestSerialization()
        {
            TransportBuilder x1 = CreateObject <TransportBuilder>().WithName("Priscilla.Builder").WithDimension(DimensionLength);

            x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);
            x1.CreateProcessRateParameter = true;
            IFormula           f1  = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty");
            IFormulaUsablePath fup = new FormulaUsablePath(new[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength);

            f1.AddObjectPath(fup);
            //WithValue to avoid formula evaluation in McAssertForSpecs-comparison.
            IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithValue(3.1);
            IParameter p2 = CreateObject <Parameter>().WithName("Pascal").WithFormula(f1).WithValue(3.2);

            x1.AddParameter(p1);
            x1.AddParameter(p2);

            ITransportBuilder x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualProcessBuilder(x1, x2);
        }
예제 #15
0
        public virtual ReferenceDTO CreateMoleculePath(DummyMoleculeContainerDTO dtoObjectBase, bool shouldCreateAbsolutePaths, IEntity refObject)
        {
            var moleculeProperties = _context.Get <IContainer>(dtoObjectBase.MoleculePropertiesContainer.Id);
            var parentContainer    = moleculeProperties.ParentContainer;

            if (parentContainer == null)
            {
                return(null);
            }
            IEnumerable <string> elements;
            IFormulaUsablePath   path;

            if (shouldCreateAbsolutePaths)
            {
                elements = _objectPathFactory.CreateAbsoluteObjectPath(parentContainer);
                path     = _objectPathFactory.CreateFormulaUsablePathFrom(elements);
            }
            else
            {
                if (refObject == parentContainer)
                {
                    path = new FormulaUsablePath();
                }
                else
                {
                    elements = _objectPathFactory.CreateRelativeObjectPath(refObject, parentContainer);
                    path     = _objectPathFactory.CreateFormulaUsablePathFrom(elements);
                }
                AdjustReferences(parentContainer, path);
            }

            path.Alias     = _aliasCreator.CreateAliasFrom(dtoObjectBase.Name);
            path.Dimension = _context.DimensionFactory.Dimension(Constants.Dimension.AMOUNT);
            path.Add(dtoObjectBase.Name);

            return(new ReferenceDTO {
                Path = path
            });
        }
예제 #16
0
 protected override void Context()
 {
     base.Context();
     _buildConfiguration = A.Fake <IBuildConfiguration>();
     _processBuilder     = new ReactionBuilder();
     _processBuilder.CreateProcessRateParameter = true;
     _kinetic            = new ExplicitFormula("(A+B)*fu/BW");
     _formulaUsablePathA = new FormulaUsablePath(new[] { ObjectPath.PARENT_CONTAINER, "A" }).WithAlias("A");
     _kinetic.AddObjectPath(_formulaUsablePathA);
     _formulaUsablePathB = new FormulaUsablePath(new[] { "B" }).WithAlias("B");
     _kinetic.AddObjectPath(_formulaUsablePathB);
     _formulaUsablePathFU = new FormulaUsablePath(new[] { ObjectPathKeywords.MOLECULE, "fu" }).WithAlias("fu");
     _kinetic.AddObjectPath(_formulaUsablePathFU);
     _formulaUsablePathBW = new FormulaUsablePath(new[] { "Organism", "BW" }).WithAlias("BW");
     _kinetic.AddObjectPath(_formulaUsablePathBW);
     _processBuilder.CreateProcessRateParameter      = true;
     _processBuilder.ProcessRateParameterPersistable = true;
     A.CallTo(() => _formulaMapper.MapFrom(_kinetic, _buildConfiguration)).Returns(_kinetic);
     _processBuilder.Name    = "Reaction";
     _processBuilder.Formula = _kinetic;
     _processRateParameter   = new Parameter();
     A.CallTo(() => _objectBaseFactory.Create <IParameter>()).Returns(_processRateParameter);
 }
        public void TestSerializationObserverBuilderWithExplicitFormula()
        {
            ContainerObserverBuilder x1 = CreateObject <ContainerObserverBuilder>().WithName("Oberon.Builder");

            x1.ForAll = false;
            x1.AddMoleculeName("H2O");
            x1.AddMoleculeName("CO2");

            ExplicitFormula    f1  = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength);
            IFormulaUsablePath fup = new FormulaUsablePath(new string[] { "aa", "bb" }).WithAlias("b").WithDimension(DimensionLength);

            f1.AddObjectPath(fup);

            IFormulaCache formulaCache = new FormulaCache();

            formulaCache.Add(f1);

            x1.Formula = formulaCache[f1.Id];

            //SerializeAndDeserializeGeneral(formulaCache);
            IObserverBuilder x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualObserverBuilder(x2, x1);
        }
예제 #18
0
        public void CreateNewPath()
        {
            var path = new FormulaUsablePath().WithDimension(_dimensionFactory.TryGetDimension(_userSettings.ParameterDefaultDimension));

            addPathToFormula(path);
        }