示例#1
0
        private async Task <IEnumerable <T> > loadModelsFromSnapshotsAsync <T>(IEnumerable <object> snapshots)
        {
            if (snapshots == null)
            {
                return(Enumerable.Empty <T>());
            }

            //This method is typically called when loading a building block snapshot directly (e.g exported as dev).
            //In this case, we are not supporting any project conversion and we just create one with the current version
            var snapshotContext = new SnapshotContext(_projectRetriever.Current, ProjectVersions.Current);
            var tasks           = snapshots.Select(x => _snapshotMapper.MapToModel(x, snapshotContext));
            var models          = await Task.WhenAll(tasks);

            return(models.OfType <T>());
        }
示例#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, };
            _defaultMapper = A.Fake <ISnapshotMapper>();
            A.CallTo(() => _snapshotMapper.MapperFor(_individualSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_individualSnapshot, A <SnapshotContext> ._)).Returns(_individual);

            A.CallTo(() => _snapshotMapper.MapperFor(_expressionProfileSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_expressionProfileSnapshot, A <SnapshotContext> ._)).Returns(_expressionProfile);

            A.CallTo(() => _snapshotMapper.MapperFor(_compoundSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_compoundSnapshot, A <SnapshotContext> ._)).Returns(_compound);

            A.CallTo(() => _snapshotMapper.MapperFor(_protocolSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_protocolSnapshot, A <SnapshotContext> ._)).Returns(_protocol);

            A.CallTo(() => _snapshotMapper.MapperFor(_formulationSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_formulationSnapshot, A <SnapshotContext> ._)).Returns(_formulation);

            A.CallTo(() => _snapshotMapper.MapperFor(_eventSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_eventSnapshot, A <SnapshotContext> ._)).Returns(_event);

            A.CallTo(() => _snapshotMapper.MapperFor(_populationSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_populationSnapshot, A <SnapshotContext> ._)).Returns(_population);

            A.CallTo(() => _snapshotMapper.MapperFor(_observerSetSnapshot)).Returns(_defaultMapper);
            A.CallTo(() => _defaultMapper.MapToModel(_observerSetSnapshot, A <SnapshotContext> ._)).Returns(_observerSet);

            A.CallTo(() => _snapshotMapper.MapToModel(_observedDataSnapshot, A <SnapshotContext> ._)).Returns(_observedData);
            A.CallTo(() => _simulationMapper.MapToModel(_simulationSnapshot, A <SimulationContext> ._)).Returns(_simulation);
            A.CallTo(() => _simulationMapper.MapToModel(_corruptedSimulationSnapshot, A <SimulationContext> ._)).Throws(new Exception());
            A.CallTo(() => _simulationComparisonMapper.MapToModel(_simulationComparisonSnapshot, A <SnapshotContext> ._)).Returns(_simulationComparison);
            A.CallTo(() => _parameterIdentificationMapper.MapToModel(_parameterIdentificationSnapshot, A <SnapshotContext> ._)).Returns(_parameterIdentification);
            A.CallTo(() => _qualificationPlanMapper.MapToModel(_qualificationPlanSnapshot, A <SnapshotContext> ._)).Returns(_qualificationPlan);
        }