protected override void Context() { _objectBaseRepository = A.Fake <IWithIdRepository>(); _objectToRegister = new Compartment().WithName("tutu").WithId("tutu"); _child1 = new PKSimParameter().WithName("toto").WithId("toto").WithFormula(new ExplicitFormula("5")); _child2 = new PKSimParameter().WithName("tata").WithId("tata").WithFormula(new ExplicitFormula("6")); _objectToRegister.Add(_child1); _objectToRegister.Add(_child2); sut = new RegisterObjectVisitor(_objectBaseRepository); }
public override async Task <ModelSimulation> MapToModel(SnapshotSimulation snapshot, SimulationContext snapshotContext) { var project = snapshotContext.Project; _logger.AddInfo(PKSimConstants.Information.LoadingSimulation(snapshot.Name, snapshotContext.NumberOfSimulationsLoaded, snapshotContext.NumberOfSimulationsToLoad), project.Name); //Local cache of ids' that will be used to retrieve original building block parameters as the project is only registered //in global context once the whole snapshot mapping process is completed var withIdRepository = new WithIdRepository(); var registrationVisitor = new RegisterObjectVisitor(withIdRepository); var simulation = await createSimulationFrom(snapshot, snapshotContext); var contextWithSimulation = new SnapshotContextWithSimulation(simulation, snapshotContext); simulation.Solver = await _solverSettingsMapper.MapToModel(snapshot.Solver, snapshotContext); simulation.OutputSchema = await _outputSchemaMapper.MapToModel(snapshot.OutputSchema, snapshotContext); simulation.OutputSelections = await _outputSelectionsMapper.MapToModel(snapshot.OutputSelections, contextWithSimulation); registrationVisitor.Register(simulation); await updateParameters(simulation, snapshot.Parameters, withIdRepository, snapshotContext); await updateAdvancedParameters(simulation, snapshot.AdvancedParameters, snapshotContext); updateUsedObservedData(simulation, snapshot.ObservedData, project); updateAlteredBuildingBlock(simulation, snapshot.AlteredBuildingBlocks); if (snapshotContext.Run) { await runSimulation(snapshot, simulation); } simulation.AddAnalyses(await individualAnalysesFrom(simulation, snapshot.IndividualAnalyses, snapshotContext)); simulation.AddAnalyses(await populationAnalysesFrom(simulation, snapshot.PopulationAnalyses, snapshotContext)); _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation); return(simulation); }