Esempio n. 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));
        }
Esempio n. 2
0
        protected override void Context()
        {
            base.Context();
            _simulationToUpdate    = A.Fake <IMoBiSimulation>();
            _templateBuildingBlock = A.Fake <IBuildingBlock>();

            var rootContainer = createRootContainer();

            _simulationToUpdate.Model.Root = rootContainer;

            _originalParameterFixedNotBelongingToTemplate       = rootContainer.Parameter("P1");
            _originalParameterFixedNotBelongingToTemplate.Value = 5;

            _originalParameterFixedUpdatedByTemplate       = rootContainer.Parameter("P2");
            _originalParameterFixedUpdatedByTemplate.Value = 8;


            _buildingBlockInfoTemplate = A.Fake <IBuildingBlockInfo>();
            A.CallTo(() => _buildingBlockInfoTemplate.UntypedTemplateBuildingBlock).Returns(_templateBuildingBlock);

            //simulates the update command
            var container = createRootContainer();

            _updatedParameterFixedNotBelongingToTemplate = container.Parameter(_originalParameterFixedNotBelongingToTemplate.Name);
            _updatedParameterFixedUpdatedByTemplate      = container.Parameter(_originalParameterFixedUpdatedByTemplate.Name);

            A.CallTo(() => _affectedBuildingBlockRetriever.RetrieveFor(_updatedParameterFixedUpdatedByTemplate, _simulationToUpdate)).Returns(_buildingBlockInfoTemplate);
            A.CallTo(() => _affectedBuildingBlockRetriever.RetrieveFor(_updatedParameterFixedNotBelongingToTemplate, _simulationToUpdate)).Returns(A.Fake <IBuildingBlockInfo>());

            A.CallTo(() => _simulationToUpdate.Update(A <IMoBiBuildConfiguration> ._, A <IModel> ._)).Invokes(x => { _simulationToUpdate.Model.Root = container; });
        }