protected override void Context()
 {
     base.Context();
     _cloneManager                = A.Fake <ICloneManager>();
     _sourceDiagramManager        = A.Fake <IReactionDiagramManager <IMoBiReactionBuildingBlock> >();
     _sourceDiagramModel          = A.Fake <IDiagramModel>();
     _newDiagramManagerFromSource = A.Fake <IReactionDiagramManager <IMoBiReactionBuildingBlock> >();
     _newDiagramModelFromSource   = A.Fake <IDiagramModel>();
     A.CallTo(() => _sourceDiagramManager.Create()).Returns(_newDiagramManagerFromSource);
     A.CallTo(() => _sourceDiagramModel.Create()).Returns(_newDiagramModelFromSource);
     _sourceReactionBuildingBlock = new MoBiReactionBuildingBlock {
         DiagramManager = _sourceDiagramManager, DiagramModel = _sourceDiagramModel
     };
 }
Exemplo n.º 2
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));
        }