예제 #1
0
        protected override void ExecuteWith(IMoBiContext context)
        {
            _modelSerialization = context.Serialize(_simulationToUpdate.Model);
            _buildConfigurationSerialization = context.Serialize(_simulationToUpdate.MoBiBuildConfiguration);
            context.UnregisterSimulation(_simulationToUpdate);
            context.PublishEvent(new SimulationUnloadEvent(_simulationToUpdate));

            var oldIdCache = getEntityIdCache(_simulationToUpdate);

            _simulationToUpdate.Update(_updatedBuildConfiguration, _newModel);

            updateReferencesToSimulation(context);

            if (_simulationToUpdate.DiagramModel != null)
            {
                replaceDiagramModelNodeIds(_simulationToUpdate.DiagramModel, oldIdCache, getEntityIdCache(_simulationToUpdate));
            }

            context.Register(_simulationToUpdate);
            _wasChanged = _simulationToUpdate.HasChanged;
            _simulationToUpdate.HasChanged = _hasChanged;

            Description = AppConstants.Commands.UpdateCommandDescription(_changedBuildingBlockName, _simulationToUpdate, _changedBuildingBlockType);

            context.PublishEvent(new SimulationReloadEvent(_simulationToUpdate));
        }
예제 #2
0
 protected override void DoExecute(IMoBiContext context)
 {
     _buildingBlock.RemoveChartTemplate(_chartTemplate.Name);
     _serializationStream = context.Serialize(_chartTemplate);
     Description          = AppConstants.Commands.RemoveChartTemplateFromBuildingBlock(_chartTemplate.Name, _buildingBlock.Name);
     context.PublishEvent(new BuildingBlockChartTemplatesModifiedEvent(_buildingBlock));
 }
예제 #3
0
        protected override void ExecuteWith(IMoBiContext context)
        {
            var project = context.CurrentProject;

            removeFromProject(project);
            context.Unregister(_buildingBlock);
            _serializationStream = context.Serialize(_buildingBlock);
            context.PublishEvent(new RemovedEvent(_buildingBlock, project));
        }
        protected override void ExecuteWith(IMoBiContext context)
        {
            context.CurrentProject.RemoveSimulation(_simulation);
            context.UnregisterSimulation(_simulation);
            context.PublishEvent(new SimulationRemovedEvent(_simulation));

            //Do not serialize Results
            _simulation.Results  = null;
            _serializationStream = context.Serialize(_simulation);
        }
        protected override void Context()
        {
            base.Context();
            _context = A.Fake <IMoBiContext>();
            A.CallTo(() => _context.Get <ISimulationSettings>(A <string> ._)).Returns(_buildingBlock);

            var serialStream = new byte[0];

            A.CallTo(() => _context.Serialize(_chartTemplate)).Returns(serialStream);
            A.CallTo(() => _context.Deserialize <CurveChartTemplate>(serialStream)).Returns(new CurveChartTemplate().WithName(_chartTemplate.Name));
        }
        protected override void ExecuteWith(IMoBiContext context)
        {
            base.ExecuteWith(context);
            _serializedParameterStartValue = context.Serialize(_startValue);
            _buildingBlock.Add(_startValue);
            if (_startValue.Formula != null)
            {
                _buildingBlock.AddFormula(_startValue.Formula);
            }

            context.PublishEvent(new StartValuesBuildingBlockChangedEvent(_buildingBlock));
        }
 protected override void DoExecute(IMoBiContext context)
 {
     _simulation.RemoveChartTemplate(_chartTemplate.Name);
     _serializationStream = context.Serialize(_chartTemplate);
     Description          = AppConstants.Commands.RemoveChartTemplateFromSimulation(_chartTemplate.Name, _simulation.Name);
 }
 public void should_serialize_old_values()
 {
     A.CallTo(() => _context.Serialize(_simulation.MoBiBuildConfiguration)).MustHaveHappened();
     A.CallTo(() => _context.Serialize(_simulation.Model)).MustHaveHappened();
 }