コード例 #1
0
 public ParameterIdentificationOutputMappingPresenter(IParameterIdentificationOutputMappingView view, IEntitiesInSimulationRetriever entitiesInSimulationRetriever,
                                                      IObservedDataRepository observedDataRepository, IOutputMappingToOutputMappingDTOMapper outputMappingDTOMapper, IQuantityToSimulationQuantitySelectionDTOMapper simulationQuantitySelectionDTOMapper,
                                                      IParameterIdentificationTask parameterIdentificationTask) : base(view)
 {
     _entitiesInSimulationRetriever        = entitiesInSimulationRetriever;
     _observedDataRepository               = observedDataRepository;
     _outputMappingDTOMapper               = outputMappingDTOMapper;
     _simulationQuantitySelectionDTOMapper = simulationQuantitySelectionDTOMapper;
     _parameterIdentificationTask          = parameterIdentificationTask;
     _allOutputMappingDTOs = new NotifyList <OutputMappingDTO>();
 }
        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);
        }