private ICommand <IMoBiContext> updateSimulation( IMoBiSimulation simulationToUpdate, IMoBiBuildConfiguration buildConfigurationReferencingTemplates, IMoBiCommand configurationCommands, IBuildingBlock templateBuildingBlock = null, PathCache <IQuantity> fixedValueQuantities = null) { //create model using referencing templates var model = createModelAndValidate(simulationToUpdate.Model.Name, buildConfigurationReferencingTemplates); var simulationBuildConfiguration = createBuildConfigurationToUseInSimulation(buildConfigurationReferencingTemplates); var updateSimulationCommand = templateBuildingBlock == null ? // is null when we a simulation is being configured. Otherwise this is the template building block to user new UpdateSimulationCommand(simulationToUpdate, model, simulationBuildConfiguration) : new UpdateSimulationCommand(simulationToUpdate, model, simulationBuildConfiguration, templateBuildingBlock); updateSimulationCommand.Run(_context); synchronizeFixedParameterValues(simulationToUpdate, templateBuildingBlock, fixedValueQuantities); var macro = new MoBiMacroCommand { Description = updateSimulationCommand.Description, CommandType = updateSimulationCommand.CommandType, ObjectType = updateSimulationCommand.ObjectType }; macro.Add(configurationCommands); macro.Add(updateSimulationCommand); return(macro); }
protected override void Context() { base.Context(); _command = A.Fake <IMoBiCommand>(); A.CallTo(() => _moleculeStartValueTask.SetIsPresent(_moleculeStartValueBuildingBlock, A <IEnumerable <IMoleculeStartValue> > ._, false)).Returns(_command); sut.Edit(_moleculeStartValueBuildingBlock); }
public ICommand UpdateSimulationFrom(IMoBiSimulation simulationToUpdate, IBuildingBlock templateBuildingBlock) { IMoBiBuildConfiguration buildConfigurationReferencingTemplate; IMoBiCommand configurationCommands = null; var fixedValueQuantities = new PathCache <IQuantity>(_entityPathResolver); if (triggersReconfiguration(templateBuildingBlock)) { using (var presenter = _applicationController.Start <IConfigureSimulationPresenter>()) { configurationCommands = presenter.CreateBuildConfigurationBaseOn(simulationToUpdate, templateBuildingBlock); if (configurationCommands.IsEmpty()) { return(new MoBiEmptyCommand()); } buildConfigurationReferencingTemplate = presenter.BuildConfiguration; } } else { buildConfigurationReferencingTemplate = createBuildConfigurationUsingTemplates(simulationToUpdate, templateBuildingBlock); fixedValueQuantities.AddRange(simulationToUpdate.Model.Root.GetAllChildren <IQuantity>(x => x.IsFixedValue)); } return(updateSimulation(simulationToUpdate, buildConfigurationReferencingTemplate, configurationCommands, templateBuildingBlock, fixedValueQuantities)); }
private IMoBiCommand withUpdatedDefaultStateAndValueOrigin(IMoBiCommand executedCommand, IFormula formula, IBuildingBlock buildingBlock) { if (executedCommand.IsEmpty()) { return(executedCommand); } var parametersUsingFormula = _parameterInBuildingBlockRetriever.AllFrom(buildingBlock, p => Equals(p.Formula, formula)); if (!parametersUsingFormula.Any()) { return(executedCommand); } var updateValueOriginCommand = new MoBiMacroCommand(); parametersUsingFormula.Each(p => updateValueOriginCommand.Add(_quantityTask.UpdateDefaultStateAndValueOriginFor(p, buildingBlock))); //we have depending parameters but they all have default state and value origin set; if (updateValueOriginCommand.IsEmtpy) { return(executedCommand); } var macroCommand = new MoBiMacroCommand().WithHistoryEntriesFrom(executedCommand); macroCommand.Add(executedCommand); macroCommand.AddRange(updateValueOriginCommand.All()); return(macroCommand); }
protected override void Context() { base.Context(); _tagDTO = new TagDTO("tag"); _removeCommand = A.Fake <IMoBiCommand>(); A.CallTo(() => _entityTask.RemoveTagFrom(_tagDTO, _parameter, _buildingBlock)).Returns(_removeCommand); }
public void Execute() { IMoBiCommand command = null; switch (_linkType) { case ReactionLinkType.Educt: // to avoid adding duplicate entries if (_reactionBuilder.Educts.All(rpb => rpb.MoleculeName != _moleculeName)) { command = new AddReactionPartnerToEductCollection(_reactionBuildingBlock, new ReactionPartnerBuilder(_moleculeName, 1.0), _reactionBuilder); } break; case ReactionLinkType.Product: if (_reactionBuilder.Products.All(rpb => rpb.MoleculeName != _moleculeName)) { command = new AddReactionPartnerToProductCollection(_reactionBuildingBlock, new ReactionPartnerBuilder(_moleculeName, 1.0), _reactionBuilder); } break; case ReactionLinkType.Modifier: if (!_reactionBuilder.ModifierNames.Contains(_moleculeName)) { command = new AddItemToModifierCollectionCommand(_reactionBuildingBlock, _moleculeName, _reactionBuilder); } break; } if (command == null) { return; } _context.AddToHistory(command.Run(_context)); }
public void Execute() { IReactionPartnerBuilder reactionPartnerBuilder; IMoBiCommand command = null; switch (_linkType) { case ReactionLinkType.Educt: reactionPartnerBuilder = _reactionBuilder.Educts.Single(educt => educt.MoleculeName.Equals(_moleculeName)); command = new RemoveReactionPartnerFromEductCollection(_reactionBuilder, reactionPartnerBuilder, _reactionBuildingBlock); break; case ReactionLinkType.Product: reactionPartnerBuilder = _reactionBuilder.Products.Single(product => product.MoleculeName.Equals(_moleculeName)); command = new RemoveReactionPartnerFromProductCollection(_reactionBuilder, reactionPartnerBuilder, _reactionBuildingBlock); break; case ReactionLinkType.Modifier: string modifierName = _reactionBuilder.ModifierNames.Single(name => name.Equals(_moleculeName)); command = new RemoveItemFromModifierCollectionCommand(_reactionBuilder, modifierName, _reactionBuildingBlock); break; } if (command == null) { return; } _context.AddToHistory(command.Run(_context)); }
protected override void Context() { base.Context(); _command = A.Fake <IMoBiCommand>(); _selectedPath = A.Fake <IFormulaUsablePath>(); sut.Edit(_tableFormulaWithXArgument, _parameter); A.CallTo(() => _selectFormulaUsablePathPresenter.GetSelection()).Returns(_selectedPath); A.CallTo(() => _formulaTask.ChangeXArgumentObject(_tableFormulaWithXArgument, _selectedPath, _buildingBlock)).Returns(_command); }
protected override void Context() { base.Context(); _synchronizeCommand = A.Fake <IMoBiCommand>(); _quantity = new Parameter(); _newValueOrigin = new ValueOrigin { Method = ValueOriginDeterminationMethods.InVitro }; A.CallTo(() => _quantitySynchronizer.Synchronize(_quantity, _simulation)).Returns(_synchronizeCommand); }
protected override void Context() { base.Context(); _buildingBlock = A.Fake <IBuildingBlock>(); _simulation = A.Fake <IMoBiSimulation>(); _createCommitChangesCommandTask = A.Fake <ICreateCommitChangesToBuildingBlockCommandTask>(); _command = A.Fake <MoBiEmptyCommand>(); A.CallTo(() => _createCommitChangesCommandTaskRetriever.TaskFor(A <IBuildingBlock> ._)).Returns(_createCommitChangesCommandTask); sut.Initialize(_buildingBlock, _simulation); A.CallTo(() => _createCommitChangesCommandTask.CreateCommitToBuildingBlockCommand(_simulation, _buildingBlock)).Returns(_command); }
public void Add <T>(T entitiyToEdit, IBuildingBlock containingBuildingBlock, IMoBiCommand changeCommand, string description) { _list.Add(new StringChange <T> { EntityToEdit = entitiyToEdit, ChangeCommand = changeCommand, ChangeDescription = description, BuildingBlock = containingBuildingBlock } ); }
protected override void Context() { base.Context(); _moleculeBuildingBlock = A.Fake <IMoleculeBuildingBlock>(); _moleculeBuilderToAdd = new MoleculeBuilder(); A.CallTo(() => _interactionTask.CorrectName(_moleculeBuilderToAdd, A <IEnumerable <string> > ._)).Returns(true); A.CallTo(() => _interactionTask.AdjustFormula(_moleculeBuilderToAdd, _moleculeBuildingBlock, A <IMoBiMacroCommand> ._)).Returns(false); A.CallTo(() => _context.PublishEvent(A <AddedEvent <IMoleculeBuilder> > ._)) .Invokes(x => _addEvent = x.GetArgument <AddedEvent <IMoleculeBuilder> >(0)); _cancelCommand = A.Fake <IMoBiCommand>(); A.CallTo(() => _interactionTaskContext.CancelCommand(A <IMoBiCommand> ._)).Returns(_cancelCommand); }
protected override void Context() { base.Context(); _simulationToConfigure = new MoBiSimulation { Model = new Model { Root = new Container() }.WithName("OLD_MODEL") }; _model = new Model().WithName("NEW MODEL"); _model.Root = new Container(); _creationResult = new CreationResult(_model); _command = new MoBiMacroCommand(); A.CallTo(() => _configurePresenter.CreateBuildConfiguration(_simulationToConfigure)).Returns(_command); A.CallTo(() => _modelConstructor.CreateModelFrom(_configurePresenter.BuildConfiguration, _simulationToConfigure.Model.Name)).Returns(_creationResult); }
protected override void Context() { base.Context(); _formula = new ExplicitFormula().WithName("Test"); _pathToRemove = new FormulaUsablePath("..", "ToRemove") { Alias = "ToRemove" }; _formulaUsablePathDTO = new FormulaUsablePathDTO(_pathToRemove, _formula); _formula.AddObjectPath(_pathToRemove); sut.InitializeWith(A.Fake <ICommandCollector>()); sut.Edit(_formula, null); _removeCommand = A.Fake <IMoBiCommand>(); A.CallTo(() => _moBiFormulaTask.RemoveFormulaUsablePath(_formula, _pathToRemove, A <IBuildingBlock> ._)).Returns(_removeCommand); }
private IMoBiCommand synchronizeStructuralBuildingBlockCommand(IParameter parameter, IBuildingBlock buildingBlock) { _command = new MoBiEmptyCommand(); if (parameter == null) { return(_command); } try { _parameter = parameter; this.Visit(buildingBlock); return(_command); } finally { _parameter = null; _command = new MoBiEmptyCommand(); } }
protected override void Because() { _command = sut.SynchronizeCommand(_quantity, _simulation); }
public void Add <T>(T entitiyToEdit, IBuildingBlock buildingBlock, IMoBiCommand changeCommand) { Add(entitiyToEdit, buildingBlock, changeCommand, changeCommand.Description); }
public void AddCommand(IMoBiCommand command) { _context.AddToHistory(command); }
protected override void Because() { _command = sut.SetIsPresent(_moleculeStartValueBuildingBlock, _startValues, isPresent: true); }
protected override void Because() { _command = sut.SetNegativeValuesAllowed(_moleculeStartValueBuildingBlock, _startValues, negativeValuesAllowed: true); }
protected override void Because() { _command = sut.RefreshStartValuesFromBuildingBlocks(_moleculeStartValueBuildingBlock, _moleculeStartValueBuildingBlock); }
protected override void Because() { _command = sut.SetConstantFormulaValue(_formula, 4, _parameter.DisplayUnit, _parameter.DisplayUnit, _buildingBlock, _parameter); }
protected override void SetAddCommandDescription(IParameter newEntity, IContainer parent, IMoBiCommand addCommand, MoBiMacroCommand macroCommand, IBuildingBlock buildingBlock) { addCommand.Description = AppConstants.Commands.AddParameterToContainerDescription(parent.EntityPath(), newEntity.Name, buildingBlock.Name); macroCommand.Description = addCommand.Description; }
/// <summary> /// Cancels the commands and returns an empty command /// </summary> /// <param name="command"></param> public IMoBiCommand CancelCommand(IMoBiCommand command) { _commandTask.ResetChanges(command, Context); return(new MoBiEmptyCommand()); }
private ICommand setSynchronizeCommand(IParameter buildingBlockParameter) { _command = buildingBlockParameter != null ? new SynchronizeParameterValueCommand(_parameter, buildingBlockParameter) : (IMoBiCommand) new MoBiEmptyCommand(); return(_command); }
private void addCommand(IMoBiCommand command) { _context.AddToHistory(command); }
protected override void Context() { base.Context(); _command = A.Fake <IMoBiCommand>(); A.CallTo(() => _interactionTask.AddNew()).Returns(_command); }
protected override void Because() { _result = sut.RemoveMultipleSimulations(_simulations); }
protected override void Because() { _result = sut.ImportStartValuesToBuildingBlock(_parameterStartValueBuildingBlock, _parameterStartValues); }
protected override void Because() { _resultCommand = sut.CreateCommitToBuildingBlockCommand(_simulation, _templateBuildingBlock); }