protected override void Context()
        {
            base.Context();

            var newObserverSetMapping = new ObserverSetMapping();

            A.CallTo(() => _observerSetTask.CreateObserverSetMapping(_observerSetTemplate1)).Returns(newObserverSetMapping);
            _newObserverSetMappingDTO = new ObserverSetMappingDTO(newObserverSetMapping);
            A.CallTo(() => _observerSetDTOMapper.MapFrom(newObserverSetMapping, _simulation)).Returns(_newObserverSetMappingDTO);
        }
Ejemplo n.º 2
0
        public IEnumerable <ObserverSet> AllUnmappedObserverSets(ObserverSetMappingDTO currentObserverSetMappingDTO = null)
        {
            var allAvailableObserverSets = _observerSetTask.All().Except(_allObserverSetMappingDTOs.Select(x => x.ObserverSet)).ToList();

            if (currentObserverSetMappingDTO?.ObserverSet != null)
            {
                allAvailableObserverSets.Insert(0, currentObserverSetMappingDTO.ObserverSet);
            }

            return(allAvailableObserverSets.OrderBy(x => x.Name));
        }
Ejemplo n.º 3
0
        private void updateObserverSetInMapping(ObserverSetMappingDTO observerSetMappingDTO, ObserverSet observerSet)
        {
            if (observerSet == null)
            {
                return;
            }

            observerSetMappingDTO.ObserverSet = observerSet;
            _view.RefreshData();
            OnStatusChanged();
        }
        protected override void Context()
        {
            base.Context();

            var newObserverSetMapping = new ObserverSetMapping();

            A.CallTo(() => _observerSetTask.CreateObserverSetMapping(_observerSetTemplate2)).Returns(newObserverSetMapping);
            _newObserverSetMappingDTO = new ObserverSetMappingDTO(newObserverSetMapping);
            sut.StatusChanged        += (o, e) => { _statusChangedNotified = true; };
            A.CallTo(() => _observerSetDTOMapper.MapFrom(newObserverSetMapping, _simulation)).Returns(_newObserverSetMappingDTO);
        }
        public ObserverSetMappingDTO MapFrom(ObserverSetMapping observerSetMapping, Simulation simulation)
        {
            var observerSetMappingDTO = new ObserverSetMappingDTO(observerSetMapping);

            var usedTemplateObserverSet = simulation.UsedBuildingBlockByTemplateId(observerSetMapping.TemplateObserverSetId);
            //simulation was already using an event based on template. Retrieved the building block used
            var templateObserverSet = _buildingBlockInSimulationManager.TemplateBuildingBlockUsedBy <ObserverSet>(usedTemplateObserverSet) ??
                                      _buildingBlockRepository.All <ObserverSet>().FindById(observerSetMapping.TemplateObserverSetId);

            observerSetMappingDTO.ObserverSet = templateObserverSet;
            return(observerSetMappingDTO);
        }
        protected override void Context()
        {
            _view = A.Fake <ISimulationObserversConfigurationView>();
            _observerSetDTOMapper            = A.Fake <IObserverSetMappingToObserverSetMappingDTOMapper>();
            _observerSetTask                 = A.Fake <IObserverSetTask>();
            _simulationBuildingBlockUpdater  = A.Fake <ISimulationBuildingBlockUpdater>();
            _buildingBlockSelectionDisplayer = A.Fake <IBuildingBlockSelectionDisplayer>();
            sut = new SimulationObserversConfigurationPresenter(_view, _observerSetDTOMapper, _observerSetTask, _simulationBuildingBlockUpdater, _buildingBlockSelectionDisplayer);


            _observerSetMapping = new ObserverSetMapping {
                TemplateObserverSetId = TEMPLATE_OBSERVER_SET_ID_1
            };

            _observerSetProperties = new ObserverSetProperties();
            _observerSetProperties.AddObserverSetMapping(_observerSetMapping);
            _simulation = new IndividualSimulation {
                Properties = new SimulationProperties {
                    ObserverSetProperties = _observerSetProperties
                }
            };

            _observerSetTemplate1 = new ObserverSet().WithName("OBSERVER_SET_1").WithId(TEMPLATE_OBSERVER_SET_ID_1);
            _observerSetTemplate2 = new ObserverSet().WithName("ANOTER_OBSERVER_SET_2").WithId(TEMPLATE_OBSERVER_SET_ID_2);

            A.CallTo(() => _observerSetTask.All()).Returns(new[] { _observerSetTemplate1, _observerSetTemplate2 });

            _observerSetMappingDTO = new ObserverSetMappingDTO(_observerSetMapping)
            {
                ObserverSet = _observerSetTemplate1
            };
            A.CallTo(() => _observerSetDTOMapper.MapFrom(_observerSetMapping, _simulation)).Returns(_observerSetMappingDTO);

            A.CallTo(() => _view.BindTo(A <IEnumerable <ObserverSetMappingDTO> > ._))
            .Invokes(x => _allObserverSetMappingDTO = x.GetArgument <IEnumerable <ObserverSetMappingDTO> >(0));

            sut.EditSimulation(_simulation, CreationMode.New);
        }
Ejemplo n.º 7
0
 private UxRepositoryItemImageComboBox initObserverSetRepository(ObserverSetMappingDTO observerSetMappingDTO)
 {
     _observerSetRepository.FillImageComboBoxRepositoryWith(_presenter.AllUnmappedObserverSets(observerSetMappingDTO), x => ApplicationIcons.Observer.Index, x => _presenter.DisplayNameFor(x));
     return(_observerSetRepository);
 }
Ejemplo n.º 8
0
 public void RemoveObserverSetMapping(ObserverSetMappingDTO observerSetMappingDTO)
 {
     _allObserverSetMappingDTOs.Remove(observerSetMappingDTO);
     OnStatusChanged();
 }
Ejemplo n.º 9
0
 public IEnumerable <ToolTipPart> ToolTipFor(ObserverSetMappingDTO observerSetMappingDTO)
 {
     return(_buildingBlockSelectionDisplayer.ToolTipFor(observerSetMappingDTO.ObserverSet));
 }
Ejemplo n.º 10
0
 public void CreateObserverFor(ObserverSetMappingDTO observerSetMappingDTO)
 {
     updateObserverSetInMapping(observerSetMappingDTO, _observerSetTask.AddToProject());
 }
Ejemplo n.º 11
0
 public async Task LoadObserverSetForAsync(ObserverSetMappingDTO observerSetMappingDTO)
 {
     updateObserverSetInMapping(observerSetMappingDTO, await _observerSetTask.LoadSingleFromTemplateAsync());
 }
 public void LoadObserverSetFor(ObserverSetMappingDTO observerSetMappingDTO)
 {
     updateObserverSetInMapping(observerSetMappingDTO, _observerSetTask.LoadSingleFromTemplate());
 }