Пример #1
0
        protected override async Task Context()
        {
            await base.Context();

            _refSimulation         = new Simulation().WithName("REF_SIM");
            _refLocalizedParameter = new LocalizedParameter {
                Path = "Organism|P", Value = 10
            };

            _simulationParameterSwap = new SimulationParameterSwap
            {
                Simulation        = _refSimulation.Name,
                Path              = _refLocalizedParameter.Path,
                TargetSimulations = new[] { "DOES NOT EXIST" },
                SnapshotFile      = "RefSnapshotPath"
            };

            _refSimulation.Parameters = new[] { _refLocalizedParameter };
            _qualificationConfiguration.SimulationParameters = new[] { _simulationParameterSwap };

            _refSnapshotProject = new SnapshotProject {
                Simulations = new[] { _refSimulation }
            };

            A.CallTo(() => _snapshotTask.LoadSnapshotFromFile <SnapshotProject>(_simulationParameterSwap.SnapshotFile)).Returns(_refSnapshotProject);
        }
Пример #2
0
        protected override async Task Context()
        {
            await base.Context();

            _creationMetaData = new CreationMetaData();
            A.CallTo(() => _creationMetaDataFactory.Create()).Returns(_creationMetaData);
            _snapshot = await sut.MapToSnapshot(_project);

            _snapshot.Version            = ProjectVersions.V7_1_0;
            _corruptedSimulationSnapshot = new Simulation();
            _snapshot.Simulations        = new[] { _snapshot.Simulations[0], _corruptedSimulationSnapshot, };
            A.CallTo(() => _snapshotMapper.MapToModel(_compoundSnapshot)).Returns(_compound);
            A.CallTo(() => _snapshotMapper.MapToModel(_individualSnapshot)).Returns(_individual);
            A.CallTo(() => _snapshotMapper.MapToModel(_protocolSnapshot)).Returns(_protocol);
            A.CallTo(() => _snapshotMapper.MapToModel(_formulationSnapshot)).Returns(_formulation);
            A.CallTo(() => _snapshotMapper.MapToModel(_eventSnapshot)).Returns(_event);
            A.CallTo(() => _snapshotMapper.MapToModel(_populationSnapshot)).Returns(_population);
            A.CallTo(() => _snapshotMapper.MapToModel(_observedDataSnapshot)).Returns(_observedData);

            A.CallTo(() => _simulationMapper.MapToModel(_simulationSnapshot, A <PKSimProject> ._)).Returns(_simulation);
            A.CallTo(() => _simulationMapper.MapToModel(_corruptedSimulationSnapshot, A <PKSimProject> ._)).Throws(new Exception());
            A.CallTo(() => _simulationComparisonMapper.MapToModel(_simulationComparisonSnapshot, A <PKSimProject> ._)).Returns(_simulationComparison);
            A.CallTo(() => _parameterIdentificationMapper.MapToModel(_parameterIdentificationSnapshot, A <PKSimProject> ._)).Returns(_parameterIdentification);
            A.CallTo(() => _qualificationPlanMapper.MapToModel(_qualificationPlanSnapshot, A <PKSimProject> ._)).Returns(_qualificationPlan);
        }
        protected override async Task Context()
        {
            await base.Context();

            var simulation = new Simulation().WithName("Sim");


            _curveChart = new CurveChart();
            simulation.IndividualAnalyses = new[] { _curveChart };
            _simulationPlot = new SimulationPlot
            {
                SectionId  = 2,
                Simulation = simulation.Name
            };
            _projectSnapshot.Simulations = new[] { simulation };
            _qualificationConfiguration.SimulationPlots = new[] { _simulationPlot };
        }
        protected override async Task Context()
        {
            await base.Context();

            _expectedOutputPath             = Path.Combine(_qualificationConfiguration.OutputFolder, PROJECT_NAME);
            DirectoryHelper.DirectoryExists = s => string.Equals(s, _expectedOutputPath);
            DirectoryHelper.DeleteDirectory = (s, b) => _deletedDirectory = s;

            _simulationName = "S1";
            _simulation     = new Simulation {
                Name = _simulationName
            };
            _individualSimulation = new IndividualSimulation {
                Name = _simulationName
            };
            _input = new Input {
                Project = PROJECT_NAME, Name = _simulationName, SectionId = 2, Type = PKSimBuildingBlockType.Simulation, SectionLevel = 5
            };

            _expectedSimulationPath = Path.Combine(_expectedOutputPath, _simulationName);
            _simulationExport       = new SimulationMapping {
                Project = PROJECT_NAME, Simulation = _simulationName, Path = _expectedSimulationPath
            };
            _simulationExports = new[] { _simulationExport };
            A.CallTo(() => _exportSimulationRunner.ExportSimulationsIn(_project, A <ExportRunOptions> ._))
            .Invokes(x => _exportOptions = x.GetArgument <ExportRunOptions>(1))
            .Returns(_simulationExports);

            _observedData = DomainHelperForSpecs.ObservedData().WithName("OBS");
            _project.AddObservedData(_observedData);
            _projectSnapshot.Simulations     = new[] { _simulation };
            _expectedObservedDataXlsFullPath = Path.Combine(_qualificationConfiguration.ObservedDataFolder, $"{_observedData.Name}{Constants.Filter.XLSX_EXTENSION}");
            _expectedObservedDataCsvFullPath = Path.Combine(_qualificationConfiguration.ObservedDataFolder, $"{_observedData.Name}{Constants.Filter.CSV_EXTENSION}");

            _expectedInputFullPath = Path.Combine(_qualificationConfiguration.InputsFolder, PROJECT_NAME, PKSimBuildingBlockType.Simulation.ToString(), $"{_simulationName}{CoreConstants.Filter.MARKDOWN_EXTENSION}");

            A.CallTo(() => _jsonSerializer.Serialize(A <QualificationMapping> ._, _qualificationConfiguration.MappingFile))
            .Invokes(x => _mapping = x.GetArgument <QualificationMapping>(0));

            _project.AddBuildingBlock(_individualSimulation);
            _qualificationConfiguration.Inputs      = new[] { _input };
            _qualificationConfiguration.Simulations = new[] { _simulationName, };
            _runOptions.Run = true;
        }
Пример #5
0
        protected override async Task Context()
        {
            await base.Context();

            var simulation = new Simulation().WithName("Sim");


            _curveChart = new CurveChart();
            simulation.IndividualAnalyses = new[] { _curveChart };
            _simulationPlot = new SimulationPlot
            {
                SectionId  = 2,
                Simulation = simulation.Name
            };
            _projectSnapshot.Simulations = new[] { simulation };
            _qualificationConfiguration.SimulationPlots = new[] { _simulationPlot };

            A.CallTo(() => _jsonSerializer.Serialize(A <QualificationMapping> ._, _qualificationConfiguration.MappingFile))
            .Invokes(x => _mapping = x.GetArgument <QualificationMapping>(0));
        }
        protected override async Task Context()
        {
            await base.Context();

            _refSimulation = new Simulation().WithName("REF_SIM");

            _simulationParameterSwap = new SimulationParameterSwap
            {
                Simulation   = _refSimulation.Name,
                Path         = "DOES NOT EXIST",
                SnapshotFile = "RefSnapshotPath"
            };

            _qualificationConfiguration.SimulationParameters = new[] { _simulationParameterSwap };

            _refSnapshotProject = new SnapshotProject {
                Simulations = new[] { _refSimulation }
            };

            A.CallTo(() => _snapshotTask.LoadSnapshotFromFileAsync <SnapshotProject>(_simulationParameterSwap.SnapshotFile)).Returns(_refSnapshotProject);
        }
Пример #7
0
        protected override Task Context()
        {
            _classificationMapper          = A.Fake <ClassificationMapper>();
            _snapshotMapper                = A.Fake <ISnapshotMapper>();
            _executionContext              = A.Fake <IExecutionContext>();
            _lazyLoadTask                  = A.Fake <ILazyLoadTask>();
            _simulationMapper              = A.Fake <SimulationMapper>();
            _simulationComparisonMapper    = A.Fake <SimulationComparisonMapper>();
            _parameterIdentificationMapper = A.Fake <ParameterIdentificationMapper>();
            _classificationSnapshotTask    = A.Fake <IClassificationSnapshotTask>();
            _qualificationPlanMapper       = A.Fake <QualificationPlanMapper>();
            _creationMetaDataFactory       = A.Fake <ICreationMetaDataFactory>();
            _logger = A.Fake <ILogger>();

            sut = new ProjectMapper(
                _simulationMapper,
                _simulationComparisonMapper,
                _parameterIdentificationMapper,
                _qualificationPlanMapper,
                _executionContext,
                _classificationSnapshotTask,
                _lazyLoadTask,
                _creationMetaDataFactory,
                _logger);


            A.CallTo(() => _executionContext.Resolve <ISnapshotMapper>()).Returns(_snapshotMapper);
            _individual               = new Individual().WithName("IND");
            _compound                 = new Compound().WithName("COMP");
            _event                    = new PKSimEvent().WithName("EVENT");
            _formulation              = new Formulation().WithName("FORM");
            _protocol                 = new SimpleProtocol().WithName("PROTO");
            _population               = new RandomPopulation().WithName("POP");
            _observedData             = new DataRepository().WithName("OD");
            _parameterIdentification  = new OSPSuite.Core.Domain.ParameterIdentifications.ParameterIdentification().WithName("PI").WithId("PI_ID");
            _classifiableObservedData = new ClassifiableObservedData {
                Subject = _observedData
            };
            _classification = new Classification {
                ClassificationType = ClassificationType.ObservedData
            }.WithName("OD Classification");
            _simulationComparison = new IndividualSimulationComparison().WithName("COMP").WithId("SimComp");
            _simulation           = new IndividualSimulation().WithName("IND_SIM").WithId("IndSim");
            _qualificationPlan    = new QualificationPlan().WithName("QP").WithId("QP_ID");
            _project = new PKSimProject();
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_formulation);
            _project.AddBuildingBlock(_protocol);
            _project.AddBuildingBlock(_population);
            _project.AddObservedData(_observedData);
            _project.AddBuildingBlock(_simulation);
            _project.AddClassifiable(_classifiableObservedData);
            _project.AddClassification(_classification);
            _project.AddSimulationComparison(_simulationComparison);
            _project.AddParameterIdentification(_parameterIdentification);
            _project.AddQualificationPlan(_qualificationPlan);

            _compoundSnapshot                              = new Snapshots.Compound();
            _individualSnapshot                            = new Snapshots.Individual();
            _eventSnapshot                                 = new Event();
            _formulationSnapshot                           = new Snapshots.Formulation();
            _protocolSnapshot                              = new Snapshots.Protocol();
            _populationSnapshot                            = new Snapshots.Population();
            _observedDataSnapshot                          = new Snapshots.DataRepository();
            _parameterIdentificationSnapshot               = new ParameterIdentification();
            _observedDataClassificationSnapshot            = new Snapshots.Classification();
            _simulationComparisonSnapshot                  = new SimulationComparison();
            _simulationClassificationSnapshot              = new Snapshots.Classification();
            _comparisonClassificationSnapshot              = new Snapshots.Classification();
            _parameterIdentificationClassificationSnapshot = new Snapshots.Classification();
            _qualificationPlanClassificationSnapshot       = new Snapshots.Classification();
            _qualificationPlanSnapshot                     = new Snapshots.QualificationPlan();
            _simulationSnapshot                            = new Simulation();


            A.CallTo(() => _snapshotMapper.MapToSnapshot(_compound)).Returns(_compoundSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_individual)).Returns(_individualSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_event)).Returns(_eventSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_formulation)).Returns(_formulationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_protocol)).Returns(_protocolSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_population)).Returns(_populationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_observedData)).Returns(_observedDataSnapshot);
            A.CallTo(() => _simulationMapper.MapToSnapshot(_simulation, _project)).Returns(_simulationSnapshot);
            A.CallTo(() => _simulationComparisonMapper.MapToSnapshot(_simulationComparison)).Returns(_simulationComparisonSnapshot);
            A.CallTo(() => _parameterIdentificationMapper.MapToSnapshot(_parameterIdentification, _project)).Returns(_parameterIdentificationSnapshot);
            A.CallTo(() => _qualificationPlanMapper.MapToSnapshot(_qualificationPlan)).Returns(_qualificationPlanSnapshot);

            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableObservedData>(_project)).Returns(new[] { _observedDataClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableSimulation>(_project)).Returns(new[] { _simulationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableComparison>(_project)).Returns(new[] { _comparisonClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableParameterIdentification>(_project)).Returns(new[] { _parameterIdentificationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableQualificationPlan>(_project)).Returns(new[] { _qualificationPlanClassificationSnapshot });

            return(_completed);
        }