public void CreateNewFromSelection() { var allMolecules = Context.CurrentProject.MoleculeBlockCollection; NewMoleculeBuildingBlockDescription newMoleculeBuildingBlockDescription = null; using (var selectMoleculesPresenter = ApplicationController.Start <ISelectMoleculesForBuildingBlockPresenter>()) { selectMoleculesPresenter.MoleculeBuildinBlocks = allMolecules; if (selectMoleculesPresenter.AskForCreation()) { newMoleculeBuildingBlockDescription = selectMoleculesPresenter.Selected; } } if (newMoleculeBuildingBlockDescription == null) { return; } var moleculeBuildingBlock = Context.Create <IMoleculeBuildingBlock>().WithName(newMoleculeBuildingBlockDescription.Name); var cloneManagerForBuildingBlocks = new CloneManagerForBuildingBlock(Context.ObjectBaseFactory, new DataRepositoryTask()) { FormulaCache = moleculeBuildingBlock.FormulaCache }; newMoleculeBuildingBlockDescription.Molecules.Each(x => moleculeBuildingBlock.Add(cloneManagerForBuildingBlocks.Clone(x))); var command = new MoBiMacroCommand { CommandType = AppConstants.Commands.AddCommand, ObjectType = ObjectName, Description = AppConstants.Commands.CreateFromSelectionDescription(moleculeBuildingBlock.Name, moleculeBuildingBlock.Select(x => x.Name).ToList()) }; command.AddCommand(GetAddCommand(moleculeBuildingBlock, null, null).Run(Context)); AddCommand(command); }
protected override void Context() { _dimensionRepository = A.Fake <IDimensionFactory>(); _dataRepositoryTask = A.Fake <IDataRepositoryTask>(); A.CallTo(() => _dimensionRepository.NoDimension).Returns(new Dimension()); _objectBaseFactory = new ObjectBaseFactoryForSpecs(_dimensionRepository); _objectToClone = createEntityToClone(); _formulaCache = new FormulaCache(); sut = new CloneManagerForBuildingBlock(_objectBaseFactory, _dataRepositoryTask); }