Ejemplo n.º 1
0
        public ITreeNode CreateFor(ISimulation simulation)
        {
            var simulationNode = CreateObjectBaseNode(simulation)
                                 .WithIcon(ApplicationIcons.Simulation);

            _observedDataRepository.All().Where(simulation.UsesObservedData).Each(observedData =>
            {
                var node = CreateFor(observedData).WithIcon(ApplicationIcons.ObservedData);
                simulationNode.AddChild(node);
            });
            return(simulationNode);
        }
Ejemplo n.º 2
0
        protected override void Context()
        {
            _buildingBlockRepository = A.Fake <IBuildingBlockRepository>();
            _buildingBockRetriever   = A.Fake <IBuildingBlockRetriever>();
            _observedDataRepository  = A.Fake <IObservedDataRepository>();
            sut = new ParameterChangeUpdater(_buildingBockRetriever, _observedDataRepository, _buildingBlockRepository);

            _compounds = new List <Compound>();
            A.CallTo(() => _buildingBlockRepository.All <Compound>()).Returns(_compounds);
            _observedDataList = new List <DataRepository>();
            A.CallTo(() => _observedDataRepository.All()).Returns(_observedDataList);

            _compound = A.Fake <Compound>().WithName("C");
            A.CallTo(() => _compound.MolWeight).Returns(200);
        }
        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);
        }
 private IEnumerable <DataRepository> allObservedDataFor(Compound compound)
 {
     return(_observedDataRepository.All()
            .Where(x => string.Equals(moleculeNameFrom(x), compound.Name)));
 }