Beispiel #1
0
        protected override void Context()
        {
            base.Context();
            _returnedBuildingBlocks = new List <IBuildingBlock>();
            _childReactionBuilder   = new ReactionBuilder().WithName("Test").WithId("FindME");
            _reactionParameter      = new Parameter().WithName("Para").WithId("ReactionPara");
            _childReactionBuilder.AddParameter(_reactionParameter);
            _reactionBuildingBlock = new MoBiReactionBuildingBlock()
            {
                _childReactionBuilder
            };
            _allBuildingBlocks.Add(_reactionBuildingBlock);
            _moleculeBuilder   = new MoleculeBuilder();
            _moleculeParameter = new Parameter().WithName("para");
            _moleculeBuilder.AddParameter(_moleculeParameter);
            _moleculeBuildingBlock = new MoleculeBuildingBlock()
            {
                _moleculeBuilder
            };
            _allBuildingBlocks.Add(_moleculeBuildingBlock);
            _passiveTranportBuilder    = new TransportBuilder();
            _passiveTransportParameter = new Parameter().WithName("PTParameter");
            _passiveTranportBuilder.AddParameter(_passiveTransportParameter);
            _passiveTranportBuildingBlock = new PassiveTransportBuildingBlock()
            {
                _passiveTranportBuilder
            };
            _allBuildingBlocks.Add(_passiveTranportBuildingBlock);
            _applicationBuilder      = new ApplicationBuilder();
            _eventGroupBuildingBlock = new EventGroupBuildingBlock()
            {
                _applicationBuilder
            };
            _applicationBuilderParameter = new ApplicationBuilder().WithName("AppParameter");
            _applicationBuilder.Add(_applicationBuilderParameter);
            _allBuildingBlocks.Add(_eventGroupBuildingBlock);
            _parameter = new Parameter().WithName("Para");
            var container = new Container().WithName("Cont");

            container.Add(_parameter);
            _objectBaseFactory = A.Fake <IObjectBaseFactory>();
            _parameterFactory  = A.Fake <IParameterFactory>();
            A.CallTo(() => _objectBaseFactory.Create <IContainer>()).Returns(new Container());
            A.CallTo(() => _objectBaseFactory.Create <IMoBiSpatialStructure>()).Returns(new MoBiSpatialStructure());
            var diagramManagerFactory = A.Fake <IDiagramManagerFactory>();

            _spatialStructure = new MoBiSpatialStructureFactory(_objectBaseFactory, _parameterFactory, A.Fake <IIconRepository>(), diagramManagerFactory).Create() as IMoBiSpatialStructure;
            _spatialStructure.AddTopContainer(container);
            _allBuildingBlocks.Add(_spatialStructure);
            _formula = new ExplicitFormula();
            _moleculeBuildingBlock.AddFormula(_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);
        }