Beispiel #1
0
        private IEnumerable <DataRepository> allPossibleObservedDataForOutput(SimulationQuantitySelectionDTO outputSelectionDTO)
        {
            if (outputSelectionDTO == null)
            {
                return(Enumerable.Empty <DataRepository>());
            }

            return(_observedDataRepository.AllObservedDataUsedBy(outputSelectionDTO.Simulation)
                   .Distinct()
                   .OrderBy(x => x.Name));
        }
        public void OutputSelectionChanged(OutputMappingDTO dto, SimulationQuantitySelectionDTO newOutput, SimulationQuantitySelectionDTO oldOutput)
        {
            if (observedDataAlreadySelectedForSameOutput(newOutput, dto.ObservedData))
            {
                dto.Output = oldOutput;
                View.CloseEditor();
                throw new CannotSelectTheObservedDataMoreThanOnceException(dto.ObservedData);
            }

            dto.Scaling = _parameterIdentificationTask.DefaultScalingFor(newOutput.Quantity);
        }
Beispiel #3
0
 public void OutputSelectionChanged(OutputMappingDTO dto, SimulationQuantitySelectionDTO newOutput, SimulationQuantitySelectionDTO oldOutput)
 {
     dto.Scaling = _parameterIdentificationTask.DefaultScalingFor(newOutput.Quantity);
 }
        protected override void Context()
        {
            _view = A.Fake <IParameterIdentificationOutputMappingView>();
            _observedDataRepository               = A.Fake <IObservedDataRepository>();
            _entitiesInSimulationRetriever        = A.Fake <IEntitiesInSimulationRetriever>();
            _outputMappingDTOMapper               = A.Fake <IOutputMappingToOutputMappingDTOMapper>();
            _simulationQuantitySelectionDTOMapper = A.Fake <IQuantityToSimulationQuantitySelectionDTOMapper>();
            _parameterIdentificationTask          = A.Fake <IParameterIdentificationTask>();

            sut = new ParameterIdentificationOutputMappingPresenter(_view, _entitiesInSimulationRetriever, _observedDataRepository, _outputMappingDTOMapper,
                                                                    _simulationQuantitySelectionDTOMapper, _parameterIdentificationTask);


            _observedData1           = DomainHelperForSpecs.ObservedData("Obs1").WithName("Obs1");
            _weightedObservedData1   = new WeightedObservedData(_observedData1);
            _observedData2           = DomainHelperForSpecs.ObservedData("Obs2").WithName("Obs2");
            _weightedObservedData2   = new WeightedObservedData(_observedData2);
            _parameterIdentification = new ParameterIdentification();
            _simulation1             = A.Fake <ISimulation>().WithId("Id1");
            _simulation2             = A.Fake <ISimulation>().WithId("Id2");
            _usedObservedData1       = new UsedObservedData {
                Id = "Obs1"
            };
            _usedObservedData2 = new UsedObservedData {
                Id = "Obs2"
            };
            A.CallTo(() => _observedDataRepository.All()).Returns(new[] { _observedData1, _observedData2 });

            A.CallTo(() => _observedDataRepository.AllObservedDataUsedBy(_simulation1)).Returns(new[] { _observedData2 });
            A.CallTo(() => _observedDataRepository.AllObservedDataUsedBy(_simulation2)).Returns(new[] { _observedData1, _observedData2 });

            _parameterIdentification.AddSimulation(_simulation1);
            _parameterIdentification.AddSimulation(_simulation2);

            _quantity1 = A.Fake <IQuantity>();
            _quantity2 = A.Fake <IQuantity>();
            _output1   = A.Fake <SimulationQuantitySelectionDTO>();
            A.CallTo(() => _output1.Simulation).Returns(_simulation1);
            _output2 = A.Fake <SimulationQuantitySelectionDTO>();
            A.CallTo(() => _output2.Simulation).Returns(_simulation2);
            A.CallTo(() => _entitiesInSimulationRetriever.OutputsFrom(_simulation1)).Returns(new PathCache <IQuantity>(new EntityPathResolverForSpecs())
            {
                { "AA", _quantity1 }
            });
            A.CallTo(() => _entitiesInSimulationRetriever.OutputsFrom(_simulation2)).Returns(new PathCache <IQuantity>(new EntityPathResolverForSpecs())
            {
                { "BB", _quantity2 }
            });
            A.CallTo(() => _simulationQuantitySelectionDTOMapper.MapFrom(_simulation1, _quantity1)).Returns(_output1);
            A.CallTo(() => _simulationQuantitySelectionDTOMapper.MapFrom(_simulation2, _quantity2)).Returns(_output2);

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


            sut.EditParameterIdentification(_parameterIdentification);

            _outputMapping1 = A.Fake <OutputMapping>();
            _outputMapping2 = A.Fake <OutputMapping>();

            _outputMappingDTO1 = new OutputMappingDTO(_outputMapping1)
            {
                Output = _output1
            };
            _outputMappingDTO2 = new OutputMappingDTO(_outputMapping2)
            {
                Output = _output2
            };

            A.CallTo(() => _outputMapping1.Simulation).Returns(_simulation1);
            A.CallTo(() => _outputMapping2.Simulation).Returns(_simulation2);

            A.CallTo(() => _outputMappingDTOMapper.MapFrom(_outputMapping1, A <IEnumerable <SimulationQuantitySelectionDTO> > ._)).Returns(_outputMappingDTO1);
            A.CallTo(() => _outputMappingDTOMapper.MapFrom(_outputMapping2, A <IEnumerable <SimulationQuantitySelectionDTO> > ._)).Returns(_outputMappingDTO2);
        }
Beispiel #5
0
 public LinkedParameterDTO(SimulationQuantitySelectionDTO simulationQuantitySimulationQuantitySelectionDTO)
 {
     SimulationQuantitySelectionDTO = simulationQuantitySimulationQuantitySelectionDTO;
 }
 private bool observedDataAlreadySelectedForSameOutput(SimulationQuantitySelectionDTO outputDTO, DataRepository observedData)
 {
     return(_allOutputMappingDTOs.Count(x => Equals(x.Output, outputDTO) && Equals(x.ObservedData, observedData)) > 1);
 }
 private static bool matches(OutputMapping outputMapping, SimulationQuantitySelectionDTO simulationQuantitySelectionDTO)
 {
     return(Equals(simulationQuantitySelectionDTO.Simulation, outputMapping.Simulation) &&
            Equals(simulationQuantitySelectionDTO.QuantityPath, outputMapping.OutputPath));
 }