protected override void Context()
        {
            base.Context();
            _sim1              = new IndividualSimulation();
            _sim2              = new IndividualSimulation();
            _repo1             = new DataRepository("1");
            _repo2             = new DataRepository("2");
            _usedObservedData1 = new UsedObservedData {
                Id = _repo1.Id
            };
            _usedObservedData2 = new UsedObservedData {
                Id = _repo2.Id
            };
            _usedObservedData3 = new UsedObservedData {
                Id = _repo1.Id
            };

            _sim1.AddUsedObservedData(_usedObservedData1);
            _sim1.AddUsedObservedData(_usedObservedData2);
            _sim2.AddUsedObservedData(_usedObservedData3);

            A.CallTo(_dialogCreator).WithReturnType <ViewResult>().Returns(ViewResult.Yes);

            _project.AddObservedData(_repo1);
            _project.AddObservedData(_repo2);
        }
Example #2
0
        public ITreeNode CreateFor(UsedObservedData usedObservedData)
        {
            var observedData = _observedDataRepository.FindFor(usedObservedData);

            return(new UsedObservedDataNode(usedObservedData, observedData)
                   .WithIcon(ApplicationIcons.ObservedData));
        }
Example #3
0
 protected override void Because()
 {
     _usedObservedData = new UsedObservedData {
         Id = "toto"
     };
     _dataRepository = new DataRepository(_usedObservedData.Id);
     A.CallTo(() => _observedDataRepository.FindFor(_usedObservedData)).Returns(_dataRepository);
     _result = sut.CreateFor(_usedObservedData);
 }
Example #4
0
        public virtual void AddUsedObservedData(UsedObservedData usedObservedData)
        {
            if (usesObservedData(usedObservedData))
            {
                return;
            }

            _usedObservedData.Add(usedObservedData);
            usedObservedData.Simulation = this;
            HasChanged = true;
        }
 protected override void Context()
 {
     base.Context();
     _usedObservedData = new UsedObservedData {
         Id = "id"
     };
     _originalSimulation             = new IndividualSimulation();
     _originalSimulation.Name        = "sim";
     _originalSimulation.Description = "desc";
     _originalSimulation.Properties  = new SimulationProperties();
     _originalSimulation.AddUsedObservedData(_usedObservedData);
 }
        protected override void Context()
        {
            base.Context();
            _simulation       = new IndividualSimulation();
            _usedObservedData = new UsedObservedData {
                Id = "dataRepositoryId", Simulation = _simulation
            };
            _dataRepository = new DataRepository(_usedObservedData.Id);
            _simulation.AddUsedObservedData(_usedObservedData);
            _parameterIdentification = new ParameterIdentification();
            _project.AddObservedData(_dataRepository);
            _project.AddParameterIdentification(_parameterIdentification);

            var outputMapping = A.Fake <OutputMapping>();

            A.CallTo(() => outputMapping.UsesObservedData(_dataRepository)).Returns(true);
            A.CallTo(() => outputMapping.UsesSimulation(_simulation)).Returns(false);
            _parameterIdentification.AddOutputMapping(outputMapping);
        }
Example #7
0
 private DataRepository observedDataFrom(UsedObservedData usedObservedDatas)
 {
     return(_projectRetriever.CurrentProject.ObservedDataBy(usedObservedDatas.Id));
 }
Example #8
0
        private IEnumerable <ParameterIdentification> findParameterIdentificationsUsing(UsedObservedData usedObservedData)
        {
            var observedData = observedDataFrom(usedObservedData);
            var simulation   = usedObservedData.Simulation;

            return(from parameterIdentification in allParameterIdentifications()
                   let outputMappings = parameterIdentification.AllOutputMappingsFor(simulation)
                                        where outputMappings.Any(x => x.UsesObservedData(observedData))
                                        select parameterIdentification);
        }
        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);
        }
Example #10
0
 private bool usesObservedData(UsedObservedData usedObservedData)
 {
     return(_usedObservedData.Contains(usedObservedData.Id));
 }
Example #11
0
 public virtual void AddObservedData(string observedDataId)
 {
     UsedObservedData.Add(observedDataId);
 }
Example #12
0
 private void updateObservedDataFrom(IEnumerable <string> usedObservedData)
 {
     UsedObservedData.Clear();
     usedObservedData.Each(UsedObservedData.Add);
 }
        protected override void Context()
        {
            _buildingBlockIconRetriever = A.Fake <IBuildingBlockIconRetriever>();
            _view = A.Fake <ISimulationExplorerView>();
            A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>());
            _treeNodeFactory    = A.Fake <ITreeNodeFactory>();
            _contextMenuFactory = A.Fake <ITreeNodeContextMenuFactory>();
            _regionResolver     = A.Fake <IRegionResolver>();
            _buildingBlockInSimulationManager = A.Fake <IBuildingBlockInSimulationManager>();
            _buildingBlockTask  = A.Fake <IBuildingBlockTask>();
            _toolTipNodeCreator = A.Fake <IToolTipPartCreator>();
            _projectRetriever   = A.Fake <IProjectRetriever>();
            _multipleTreeNodeContextMenuFactory      = A.Fake <IMultipleTreeNodeContextMenuFactory>();
            _parameterAnalysablesInExplorerPresenter = A.Fake <IParameterAnalysablesInExplorerPresenter>();
            _simulationComparisonTask = A.Fake <ISimulationComparisonTask>();
            _simulationFolderNode     = new RootNode(RootNodeTypes.SimulationFolder);
            _comparisonFolderNode     = new RootNode(RootNodeTypes.ComparisonFolder);
            _project          = new PKSimProject();
            _usedObservedData = new UsedObservedData {
                Id = "UsedData"
            };
            _simulation           = new IndividualSimulation().WithName("individualSimulation").WithId("individualSimulation");
            _populationSimulation = new PopulationSimulation().WithName("populationSimulation").WithId("populationSimulation");
            _importedSimulaton    = A.Fake <Simulation>().WithName("ImportedSimulation").WithId("ImportedSimulation");
            A.CallTo(() => _importedSimulaton.IsImported).Returns(true);
            _simulation.Properties                   = new SimulationProperties();
            _simulation.ModelProperties              = new ModelProperties();
            _simulation.ModelConfiguration           = A.Fake <ModelConfiguration>();
            _populationSimulation.Properties         = new SimulationProperties();
            _populationSimulation.ModelProperties    = new ModelProperties();
            _populationSimulation.ModelConfiguration = A.Fake <ModelConfiguration>();
            _classificationPresenter                 = A.Fake <IClassificationPresenter>();
            _project.AddBuildingBlock(_simulation);
            _project.AddBuildingBlock(_populationSimulation);
            var classifiableIndividualSimulation = new ClassifiableSimulation {
                Subject = _simulation
            };
            var classfiablePopulationSimulation = new ClassifiableSimulation {
                Subject = _populationSimulation
            };
            var classifiableImportSimulation = new ClassifiableSimulation {
                Subject = _importedSimulaton
            };

            _project.AddClassifiable(classifiableIndividualSimulation);
            _project.AddClassifiable(classfiablePopulationSimulation);
            _individualSimulationNode = new SimulationNode(classifiableIndividualSimulation);
            _populationSimulationNode = new SimulationNode(classfiablePopulationSimulation);
            _importedSimulationNode   = new SimulationNode(classifiableImportSimulation);
            _usedObservedDataNode     = A.Fake <ITreeNode>();
            A.CallTo(() => _treeNodeFactory.CreateFor(classifiableIndividualSimulation)).Returns(_individualSimulationNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(classfiablePopulationSimulation)).Returns(_populationSimulationNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(classifiableImportSimulation)).Returns(_importedSimulationNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(_usedObservedData)).Returns(_usedObservedDataNode);
            _project.AddBuildingBlock(_importedSimulaton);

            var simulationComparison   = A.Fake <ISimulationComparison>().WithId("SimComp_Id");
            var classifiableComparison = new ClassifiableComparison {
                Subject = simulationComparison
            };

            _comparisonNode = new ComparisonNode(classifiableComparison);
            _project.AddSimulationComparison(simulationComparison);
            A.CallTo(() => _treeNodeFactory.CreateFor(classifiableComparison)).Returns(_comparisonNode);


            _usedCompoundBuildingBlock = new UsedBuildingBlock("toto", PKSimBuildingBlockType.Compound)
            {
                Id = "usedBB"
            };
            _simulation.AddUsedBuildingBlock(_usedCompoundBuildingBlock);
            _simulation.AddUsedObservedData(_usedObservedData);

            _project.AddClassifiable(classifiableComparison);

            _templageCompoundBuildingBlock = A.Fake <IPKSimBuildingBlock>();
            _usedBuildingBlockNode         = new UsedBuildingBlockInSimulationNode(_simulation, _usedCompoundBuildingBlock, _templageCompoundBuildingBlock);
            A.CallTo(() => _treeNodeFactory.CreateFor(_simulation, _usedCompoundBuildingBlock)).Returns(_usedBuildingBlockNode);
            A.CallTo(() => _buildingBlockIconRetriever.IconFor(_simulation)).Returns(ApplicationIcons.SimulationGreen);
            A.CallTo(() => _buildingBlockIconRetriever.IconFor(_populationSimulation)).Returns(ApplicationIcons.SimulationGreen);
            A.CallTo(() => _buildingBlockIconRetriever.IconFor(_usedCompoundBuildingBlock)).Returns(ApplicationIcons.CompoundRed);
            A.CallTo(() => _view.TreeView.NodeById(_simulation.Id)).Returns(_individualSimulationNode);
            A.CallTo(() => _view.TreeView.NodeById(_usedCompoundBuildingBlock.Id)).Returns(_usedBuildingBlockNode);
            A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.SimulationFolder.Id)).Returns(_simulationFolderNode);
            A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ComparisonFolder.Id)).Returns(_comparisonFolderNode);

            _observedDataInSimulationManager = A.Fake <IObservedDataInSimulationManager>();
            sut = new SimulationExplorerPresenter(
                _view, _treeNodeFactory, _contextMenuFactory,
                _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever,
                _regionResolver, _buildingBlockTask, _buildingBlockInSimulationManager,
                _toolTipNodeCreator, _projectRetriever, _classificationPresenter,
                _parameterAnalysablesInExplorerPresenter, _observedDataInSimulationManager, _simulationComparisonTask);

            A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project);
        }
 public DataRepository FindFor(UsedObservedData usedObservedData)
 {
     return(All().FindById(usedObservedData.Id));
 }