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)); }
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); }