Пример #1
0
        /// <summary>
        ///     Adds all reactionBuilders to the Reaction Building Block and adds the Reaction Building
        ///     Block to the MoBi Project.
        /// </summary>
        public override void AddToProject()
        {
            foreach (var reaction in ReactionBuilderList)
            {
                _reactionBuildingBlock.Add(reaction);
            }

            foreach (var passiveTransport in _passiveTransportList)
            {
                _passiveTransportBuildingBlock.Add(passiveTransport);
            }

            _context.AddToHistory(new AddBuildingBlockCommand <IMoBiReactionBuildingBlock>(_reactionBuildingBlock).Run(_context));
            _context.AddToHistory(new AddBuildingBlockCommand <IPassiveTransportBuildingBlock>(_passiveTransportBuildingBlock).Run(_context));
        }
        protected override void Context()
        {
            _buildConfiguration           = new MoBiBuildConfiguration();
            _moleculeBuidingBlock         = new MoleculeBuildingBlock().WithName("M");
            _buildConfiguration.Molecules = _moleculeBuidingBlock;

            _reactionBuildingBlock = new MoBiReactionBuildingBlock().WithName("R");
            _reactionBuildingBlock.Add(new ReactionBuilder().WithName("R1"));
            _buildConfiguration.Reactions = _reactionBuildingBlock;

            _passiveTransportBuildingBlock = new PassiveTransportBuildingBlock().WithName("PT");
            _passiveTransportBuildingBlock.Add(new TransportBuilder().WithName("PT2"));
            _passiveTransportBuildingBlock.Add(new TransportBuilder().WithName("PT1"));
            _buildConfiguration.PassiveTransports = _passiveTransportBuildingBlock;

            _eventGroupBuildingBlock        = new EventGroupBuildingBlock().WithName("EG");
            _buildConfiguration.EventGroups = _eventGroupBuildingBlock;

            _msvBuildingBlock = new MoleculeStartValuesBuildingBlock().WithName("MSV");
            _buildConfiguration.MoleculeStartValues = _msvBuildingBlock;

            _psvBuildingBlock = new ParameterStartValuesBuildingBlock().WithName("PSV");
            _buildConfiguration.ParameterStartValues = _psvBuildingBlock;

            _spatialStructure = new MoBiSpatialStructure().WithName("SPST");
            _buildConfiguration.SpatialStructure = _spatialStructure;

            _observerBuildingBlock        = new ObserverBuildingBlock().WithName("O");
            _buildConfiguration.Observers = _observerBuildingBlock;

            _objectPathFactory  = new ObjectPathFactory(new AliasCreator());
            _entityPathResolver = new EntityPathResolver(_objectPathFactory);
            sut = new AffectedBuildingBlockRetriever(_entityPathResolver);

            //common setup
            _simulation = new MoBiSimulation {
                BuildConfiguration = _buildConfiguration
            };
        }
Пример #3
0
        protected override void Context()
        {
            base.Context();
            _reactionBuildingBlock = new MoBiReactionBuildingBlock
            {
                DiagramModel   = new DiagramModel(),
                DiagramManager = new MoBiReactionDiagramManager()
            };

            _moBiReactionDiagramManager = _reactionBuildingBlock.DiagramManager.DowncastTo <IReactionDiagramManager <IMoBiReactionBuildingBlock> >();

            _moBiReactionDiagramManager.InitializeWith(_reactionBuildingBlock, A.Fake <IDiagramOptions>());

            _molecule = new MoleculeBuilder().WithId("moleculeId").WithName("moleculeName");
            _reaction = new ReactionBuilder().WithId("reactionId");
            _reaction.AddEduct(new ReactionPartnerBuilder(_molecule.Name, 1.0));
            _reactionBuildingBlock.Add(_reaction);
            _moBiReactionDiagramManager.AddObjectBase(_reaction);
            _moBiReactionDiagramManager.AddMolecule(_reaction, "moleculeName");
            _moleculeNode           = _moBiReactionDiagramManager.GetMoleculeNodes("moleculeName").FirstOrDefault();
            _reactionNode           = _moBiReactionDiagramManager.PkModel.DiagramModel.GetAllChildren <ReactionNode>().FirstOrDefault();
            _interactionTask        = A.Fake <IInteractionTasksForChildren <IMoBiReactionBuildingBlock, IReactionBuilder> >();
            _activeSubjectRetriever = A.Fake <IActiveSubjectRetriever>();

            var reactionLink = new ReactionLink();

            reactionLink.Initialize(ReactionLinkType.Educt, _reactionNode, _moleculeNode);

            sut.Edit(_reactionBuildingBlock);

            var removeReactionCommand = new RemoveCommandFor <IMoBiReactionBuildingBlock, IReactionBuilder>(_interactionTask, _moBiContext, _activeSubjectRetriever);

            A.CallTo(() => _moBiContext.Get <IReactionBuilder>(_reaction.Id)).Returns(_reaction);
            A.CallTo(() => _moBiContext.Resolve <RemoveCommandFor <IMoBiReactionBuildingBlock, IReactionBuilder> >()).Returns(removeReactionCommand);
            A.CallTo(() => _activeSubjectRetriever.Active <IBuildingBlock>()).Returns(_reactionBuildingBlock);
            A.CallTo(() => _interactionTask.Remove(_reaction, _reactionBuildingBlock, _reactionBuildingBlock, A <bool> ._)).Invokes(x => _reactionBuildingBlock.Remove(_reaction));
        }