コード例 #1
0
        protected override void Context()
        {
            base.Context();
            _individualPropertiesCache = A.Fake <IndividualValuesCache>();
            _patchCache = new PathCacheForSpecs <IParameter>();
            var individualParameter = A.Fake <IParameter>();

            A.CallTo(() => individualParameter.IsChangedByCreateIndividual).Returns(true);
            _patchCache.Add("Path1", individualParameter);

            var advancedParameter = A.Fake <IParameter>();

            A.CallTo(() => advancedParameter.IsChangedByCreateIndividual).Returns(false);
            advancedParameter.CanBeVariedInPopulation = true;
            _patchCache.Add("PathAdvanced", advancedParameter);

            A.CallTo(() => _individualPropertiesCache.AllParameterPaths()).Returns(new[] { "Path1", "Path2", "PathAdvanced" });
            A.CallTo(() => _individualPropertiesCache.ParameterValuesFor("Path1")).Returns(_value1);
            A.CallTo(() => _individualPropertiesCache.ParameterValuesFor("Path2")).Returns(_value2);
            A.CallTo(() => _individualPropertiesCache.ParameterValuesFor("PathAdvanced")).Returns(_value3);
            _populationSimulation = A.Fake <PopulationSimulation>();
            _parameterValueCache  = A.Fake <ParameterValuesCache>();
            A.CallTo(() => _populationSimulation.ParameterValuesCache).Returns(_parameterValueCache);
            _mobiPopulation = A.Fake <MoBiPopulation>();
            A.CallTo(_simulationFactory).WithReturnType <PopulationSimulation>().Returns(_populationSimulation);
            A.CallTo(() => _objectBaseFactory.Create <MoBiPopulation>()).Returns(_mobiPopulation);
            A.CallTo(() => _parameterRetriever.ParametersFrom(_populationSimulation)).Returns(_patchCache);
            A.CallTo(() => _individualPropertiesCacheImporter.ImportFrom(_populationFile, _patchCache, A <IImportLogger> ._)).Returns(_individualPropertiesCache);

            _advancedParameterContainer = new AdvancedParameter();
            A.CallTo(() => _advancedParameterFactory.Create(advancedParameter, DistributionTypes.Unknown)).Returns(_advancedParameterContainer);
        }
コード例 #2
0
 protected override void Context()
 {
     base.Context();
     _sourceParameters = new PathCacheForSpecs <IParameter>();
     _targetParameters = new PathCacheForSpecs <IParameter>();
     _sourceParameter  = new PKSimParameter().WithName("toto").WithId("1").WithParentContainer(new Container().WithName("Cont"));
     _targetParameter  = new PKSimParameter().WithName("toto").WithId("10").WithParentContainer(new Container().WithName("Cont"));
     _targetParameter2 = new PKSimParameter().WithName("titi").WithId("20").WithParentContainer(new Container().WithName("Cont"));
     _sourceParameters.Add(_sourceParameter);
     _targetParameters.Add(_targetParameter);
     _targetParameters.Add(_targetParameter2);
 }
コード例 #3
0
 protected override void Context()
 {
     base.Context();
     _allImportedParameters.AddRange(new[] { "P1", "P2" });
     _allParameters.Add("P1", new PKSimParameter().WithName("P1"));
     _allParameters.Add("P2", new PKSimParameter().WithName("P2"));
     _allCreateIndividualParameters.Add("P1", _allParameters.FindByName("P1"));
     _advancedParameter = new AdvancedParameter();
     A.CallTo(() => _containerTask.CacheAllChildren <IParameter>(_cloneIndividual)).Returns(_allParameters);
     A.CallTo(() => _containerTask.CacheAllChildrenSatisfying(_cloneIndividual, A <Func <IParameter, bool> > ._)).Returns(_allCreateIndividualParameters);
     A.CallTo(() => _advancedParameterFactory.Create(_allParameters.FindByName("P2"), DistributionTypes.Unknown)).Returns(_advancedParameter);
     A.CallTo(() => _createdPopulation.IndividualPropertiesCache.AllParameterPaths()).Returns(_allImportedParameters);
 }
コード例 #4
0
 protected override void Context()
 {
     base.Context();
     _populationAnalysis      = A.Fake <PopulationStatisticalAnalysis>();
     _populationDataCollector = A.Fake <IPopulationDataCollector>();
     _allOutputs = new PathCacheForSpecs <IQuantity>();
     _allOutputs.Add(new Observer {
         Name = "obs"
     });
     _allOutputs.Add(new Observer {
         Name = "obs2"
     });
     A.CallTo(() => _outputsRetriever.OutputsFrom(_populationDataCollector)).Returns(_allOutputs);
 }
        protected override void Context()
        {
            _view = A.Fake <IPopulationAnalysisFieldsView>();
            _quantitiesRetriever            = A.Fake <IEntitiesInContainerRetriever>();
            _contextMenuFactory             = A.Fake <IPopulationAnalysesContextMenuFactory>();
            _populationAnalysisFieldFactory = A.Fake <IPopulationAnalysisFieldFactory>();
            _populationAnalysisTemplateTask = A.Fake <IPopulationAnalysisTemplateTask>();
            _dialogCreator  = A.Fake <IDialogCreator>();
            _fieldDTOMapper = A.Fake <IPopulationAnalysisFieldToPopulationAnalysisFieldDTOMapper>();
            _parameterCache = new PathCacheForSpecs <IParameter>();
            _eventPublisher = A.Fake <IEventPublisher>();
            _populationAnalysisGroupingFieldCreator = A.Fake <IPopulationAnalysisGroupingFieldCreator>();
            sut = new PopulationAnalysisParameterFieldsPresenter(_view, _contextMenuFactory, _quantitiesRetriever, _populationAnalysisFieldFactory,
                                                                 _eventPublisher, _populationAnalysisGroupingFieldCreator, _populationAnalysisTemplateTask, _dialogCreator, _fieldDTOMapper);

            A.CallTo(_quantitiesRetriever).WithReturnType <PathCache <IParameter> >().Returns(_parameterCache);
            _populationPivotAnalysis = new PopulationPivotAnalysis();
            _populationDataCollector = A.Fake <IPopulationDataCollector>();
            sut.StartAnalysis(_populationDataCollector, _populationPivotAnalysis);

            _parameter      = A.Fake <IParameter>();
            _parameterField = new PopulationAnalysisParameterField {
                ParameterPath = _parameterPath, Name = "ParameterField"
            };
            A.CallTo(() => _populationAnalysisFieldFactory.CreateFor(_parameter)).Returns(_parameterField);

            _derivedField = A.Fake <PopulationAnalysisDerivedField>();
            A.CallTo(() => _derivedField.ReferencedFieldNames).Returns(new[] { _parameterField.Name });

            _parameterCache.Add(_parameterPath, _parameter);
        }
コード例 #6
0
        protected RandomPopulation CreateRandomPopulation()
        {
            var pop = new RandomPopulation();

            pop.Settings = new RandomPopulationSettings();
            var cache = new PathCache <IParameter>(_entityPathResolver);

            cache.Add("PATH1", DomainHelperForSpecs.ConstantParameterWithValue(4).WithName("PARA1"));
            cache.Add("PATH2", DomainHelperForSpecs.ConstantParameterWithValue(5).WithName("PARA2"));
            pop.IndividualPropertiesCache.ParameterValuesCache.Add(new[] { new ParameterValue("PATH1", 1, 0.1), new ParameterValue("PATH2", 2, 0.2) });
            pop.IndividualPropertiesCache.ParameterValuesCache.Add(new[] { new ParameterValue("PATH1", 11, 0.11), new ParameterValue("PATH2", 11, 0.22) });
            pop.Settings.BaseIndividual = DomainHelperForSpecs.CreateIndividual();
            A.CallTo(() => _containerTask.CacheAllChildren <IParameter>(pop.Settings.BaseIndividual)).Returns(cache);

            return(pop);
        }
コード例 #7
0
        public virtual PathCache <IParameter> AllParameters(IEntityPathResolver entityPathResolver)
        {
            var allParameters = new PathCache <IParameter>(entityPathResolver).For(AllPotentialAdvancedParameters);

            foreach (var populationParameters in Population.AllParameters(entityPathResolver).KeyValues)
            {
                if (!allParameters.Contains(populationParameters.Key))
                {
                    allParameters.Add(populationParameters.Key, populationParameters.Value);
                }
            }
            return(allParameters);
        }
コード例 #8
0
        public void ShouldMakePassedRuleCheckAllItsPaths()
        {
            //GIVEN
            var pathCache = new PathCache(Any.Instance <IDependencyPathFactory>());
            var rule      = Substitute.For <IDependencyRule>();
            var report    = Any.Instance <IAnalysisReportInProgress>();
            var path1     = Any.Instance <IProjectDependencyPath>();
            var path2     = Any.Instance <IProjectDependencyPath>();
            var path3     = Any.Instance <IProjectDependencyPath>();

            pathCache.Add(path1);
            pathCache.Add(path2);
            pathCache.Add(path3);

            //WHEN
            pathCache.Check(rule, report);

            //THEN
            rule.Received(1).Check(report, path1);
            rule.Received(1).Check(report, path2);
            rule.Received(1).Check(report, path3);
        }
コード例 #9
0
        public override System.Collections.Generic.IEnumerable <INodeFactory> ResolvePath(
            PowerShell.Provider.PathNodeProcessors.IContext context, string path)
        {
            path = context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(path);

            var nf = PathCache.Get(path);

            if (null != nf)
            {
                return(nf);
            }

            var driveInfo = GetDriveFromPath(context, path);

            if (null == driveInfo)
            {
                context.WriteWarning(String.Format("Could not determine drive for path [{0}]", path));
                return(base.ResolvePath(context, path));
            }

            string fileOrServerPath = Regex.Replace(path, @"^[^::]+::", String.Empty);

            var re      = new Regex("^.*(" + Regex.Escape(driveInfo.Root) + ")(.*)$", RegexOptions.IgnoreCase);
            var matches = re.Match(path);

            fileOrServerPath = matches.Groups[1].Value;
            path             = matches.Groups[2].Value;

            if (File.Exists(fileOrServerPath) || Directory.Exists(fileOrServerPath))
            {
                _root = new BipsFileRootNodeFactory(driveInfo, fileOrServerPath);
            }
            else
            {
                _root = new BipsRootNodeFactory(driveInfo);
            }

            var nodes = base.ResolvePath(context, path);

            if (null == nodes || !nodes.Any())
            {
                return(nodes);
            }

            nodes = nodes.ToList();

            PathCache.Add(path, nodes);

            return(nodes);
        }
コード例 #10
0
 protected override void Context()
 {
     base.Context();
     _context                = A.Fake <IExecutionContext>();
     _quantityRetriever      = A.Fake <IEntitiesInContainerRetriever>();
     _populationAnalysisTask = A.Fake <IPKAnalysesTask>();
     _pkAnalyses             = A.Fake <PopulationSimulationPKAnalyses>();
     _quantityCache          = new PathCacheForSpecs <IQuantity>();
     _quantity1              = new MoleculeAmount();
     _quantity2              = new MoleculeAmount();
     _quantityCache.Add("PATH1", _quantity1);
     _quantityCache.Add("PATH2", _quantity2);
     A.CallTo(() => _context.Resolve <IEntitiesInContainerRetriever>()).Returns(_quantityRetriever);
     A.CallTo(() => _context.Resolve <IPKAnalysesTask>()).Returns(_populationAnalysisTask);
     A.CallTo(() => _quantityRetriever.QuantitiesFrom(_populationSimulation)).Returns(_quantityCache);
     A.CallTo(() => _populationAnalysisTask.CalculateFor(_populationSimulation)).Returns(_pkAnalyses);
     _allQuantityPaths = new List <string> {
         "PATH1", "PATH2"
     };
     _simulationSettings = new OutputSelections();
     A.CallTo(() => _populationSimulation.OutputSelections).Returns(_simulationSettings);
     A.CallTo(() => _simulationResults.AllQuantityPaths()).Returns(_allQuantityPaths);
 }
コード例 #11
0
        public PathCache <IQuantity> OutputsFrom(ISimulation simulation)
        {
            var allQuantities = QuantitiesFrom(simulation);
            var outputs       = new PathCache <IQuantity>(_entityPathResolver);

            foreach (var selectedQuantity in simulation.OutputSelections)
            {
                var quantity = allQuantities[selectedQuantity.Path];
                if (quantity != null)
                {
                    outputs.Add(quantity);
                }
            }

            return(outputs);
        }
コード例 #12
0
        public override void LoadDataAsync(LoadCommand cmd, LoadDataAsyncParameters cmdParam, Action <PaneViewModelBase> success = null, Action <PaneViewModelBase, Exception> error = null)
        {
            base.LoadDataAsync(cmd, cmdParam, success, error);
            switch (cmd)
            {
            case LoadCommand.Load:
                Initialize();
                SetFavorites();
                var drive = GetDriveFromPath(Settings.Directory);
                if (drive != null)
                {
                    PathCache.Add(drive, Settings.Directory);
                }
                Drive = drive ?? GetDefaultDrive();
                break;

            case LoadCommand.Restore:
                var payload = cmdParam.Payload as BinaryContent;
                if (payload == null)
                {
                    return;
                }
                WorkHandler.Run(
                    () =>
                {
                    File.WriteAllBytes(payload.FilePath, payload.Content);
                    return(true);
                },
                    result =>
                {
                    if (success != null)
                    {
                        success.Invoke(this);
                    }
                },
                    exception =>
                {
                    if (error != null)
                    {
                        error.Invoke(this, exception);
                    }
                });
                break;
            }
        }
コード例 #13
0
        protected override void Context()
        {
            base.Context();
            _populationAnalysis      = A.Fake <PopulationStatisticalAnalysis>();
            _populationDataCollector = A.Fake <IPopulationDataCollector>();
            _allOutputs = new PathCacheForSpecs <IQuantity>();
            _oneOutput  = new Observer {
                Name = "obs"
            };
            _allOutputs.Add(_oneOutput);
            A.CallTo(() => _outputsRetriever.OutputsFrom(_populationDataCollector)).Returns(_allOutputs);
            var dto = new QuantitySelectionDTO {
                Quantity = _oneOutput
            };

            dto.PathElements.Add(PathElement.TopContainer, new PathElementDTO {
                DisplayName = "TOTO"
            });
            A.CallTo(() => _allOutputsPresenter.QuantityDTOByPath(_allOutputs.Keys.First())).Returns(dto);
        }
コード例 #14
0
        protected override void Context()
        {
            base.Context();
            _populationDataCollector    = A.Fake <IPopulationDataCollector>();
            _templatePopulationAnalysis = new PopulationPivotAnalysis();

            _parameterFound = new PopulationAnalysisParameterField {
                ParameterPath = "P1"
            };
            _parameterNotFound = new PopulationAnalysisParameterField {
                ParameterPath = "P2"
            };

            _templatePopulationAnalysis.Add(_parameterFound);
            _templatePopulationAnalysis.Add(_parameterNotFound);

            _cache = new PathCacheForSpecs <IParameter>();
            _cache.Add("P1", new PKSimParameter());

            A.CallTo(_templateTask).WithReturnType <PopulationAnalysis>().Returns(_templatePopulationAnalysis);

            A.CallTo(() => _entitiesInContainerRetriever.ParametersFrom(_populationDataCollector)).Returns(_cache);
            A.CallTo(_dialogCreator).WithReturnType <ViewResult>().Returns(ViewResult.Yes);
        }
コード例 #15
0
        protected override void Context()
        {
            var entityPathFactory = new EntityPathResolverForSpecs();

            _objectPathFactory   = new ObjectPathFactory(new AliasCreator());
            _simulation          = A.Fake <IModelCoreSimulation>().WithName("Sim");
            _simModelManager     = A.Fake <ISimModelManager>();
            _containerTask       = A.Fake <IContainerTask>();
            _options             = new ScaleDivisorOptions();
            _moleculeAmountCache = new PathCache <IMoleculeAmount>(entityPathFactory);
            var rootContainer = new ARootContainer().WithName(_simulation.Name)
                                .WithContainerType(ContainerType.Simulation);

            _simulation.Model.Root = rootContainer;
            _moleculeAmount1       = new MoleculeAmount().WithName("M1");
            _moleculeAmount2       = new MoleculeAmount().WithName("M2");

            rootContainer.Add(_moleculeAmount1);
            rootContainer.Add(_moleculeAmount2);

            _moleculeAmountCache.Add(_moleculeAmount1);
            _moleculeAmountCache.Add(_moleculeAmount2);

            _molecule1Path = entityPathFactory.PathFor(_moleculeAmount1);
            _molecule2Path = entityPathFactory.PathFor(_moleculeAmount2);

            _originalResults    = new DataRepository();
            _simulation.Results = _originalResults;

            var baseGrid = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION)
            {
                Values = new[] { 0f, 1f, 2f, 3f }
            };

            _originalDataColumn = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid)
            {
                Values = new[] { 0f, 10f, 20f, 30f }
            };
            _originalDataColumn.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1);
            _originalResults.Add(_originalDataColumn);

            A.CallTo(_containerTask).WithReturnType <PathCache <IMoleculeAmount> >().Returns(_moleculeAmountCache);
            var simResults = new DataRepository();
            var baseGrid2  = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION)
            {
                Values = new[] { 0f, 1f, 2f, 3f }
            };
            var res1 = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid2)
            {
                Values = new[] { 0f, 10f, 20f, 30f }
            };

            res1.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1);
            simResults.Add(res1);

            var res2 = new DataColumn("M2", Constants.Dimension.NO_DIMENSION, baseGrid2)
            {
                Values = new[] { 0f, 11f, 12f, 13f }
            };

            res2.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount2);
            simResults.Add(res2);

            var simulationRunResults = new SimulationRunResults(true, Enumerable.Empty <ISolverWarning>(), simResults);

            A.CallTo(() => _simModelManager.RunSimulation(_simulation)).Returns(simulationRunResults);
            sut = new ScaleDivisorCalculator(_simModelManager, _containerTask, _objectPathFactory);
        }
コード例 #16
0
        private void ConnectCallback()
        {
            _doContentScanOn.Clear();
            Initialize();
            SetFavorites();
            var defaultPath = string.IsNullOrEmpty(Connection.Model.DefaultPath)
                                  ? GetDefaultDrive()
                                  : Connection.Model.DefaultPath;

            var drive = GetDriveFromPath(defaultPath);

            if (drive != null && FileManager.FolderExists(defaultPath))
            {
                PathCache.Add(drive, defaultPath);
            }
            Drive = drive ?? Drives.First();

            if (!IsContentScanTriggerAvailable)
            {
                return;
            }

            //HACK: for testing purposes only
            if (FileManager.ServerType == FtpServerType.IIS)
            {
                ScanFolders = new Dictionary <int, FsdScanPath>()
                {
                    { 1, new FsdScanPath
                      {
                          PathId    = 1,
                          Path      = "/Hdd1/Content/0000000000000000/",
                          ScanDepth = 2,
                          Drive     = "Hdd1"
                      } }
                };
                return;
            }

            var credentials = GetHttpLogin();
            var username    = credentials.UserName;
            var password    = credentials.Password;

            switch (GetScanFolders(username, password))
            {
            case HttpStatusCode.OK:
                if (!UserSettingsProvider.DisableFsdStatusPolling)
                {
                    _statusUpdateTimer.Elapsed += StatusUpdateTimerOnElapsed;
                    _statusUpdateTimer.Start();
                }
                return;

            case HttpStatusCode.Unauthorized:
                bool result;
                do
                {
                    var loginViewModel = Container.Resolve <ILoginViewModel>();
                    loginViewModel.Title    = Resx.Login;
                    loginViewModel.Message  = Resx.LoginToFreestyleDashHttpServer;
                    loginViewModel.Username = username;
                    loginViewModel.Password = password;
                    loginViewModel.IsRememberPasswordEnabled = true;

                    var login = WindowManager.ShowLoginDialog(loginViewModel);
                    if (login == null)
                    {
                        var answer = (DisableOption)WindowManager.ShowListInputDialog(Resx.DisableFsdContentScanTriggerTitle, Resx.DisableFsdContentScanTriggerMessage, DisableOption.None, GetDisableOptionList());
                        switch (answer)
                        {
                        case DisableOption.All:
                            UserSettingsProvider.FsdContentScanTrigger = FsdContentScanTrigger.Disabled;
                            break;

                        case DisableOption.Single:
                            Connection.IsHttpAccessDisabled = true;
                            break;
                        }
                        result = true;
                    }
                    else
                    {
                        username = login.Username;
                        password = login.Password;
                        var status = GetScanFolders(username, password);
                        if (status != HttpStatusCode.OK && status != HttpStatusCode.Unauthorized)
                        {
                            //TODO: handle different result then the previous one
                            result = true;
                        }
                        else
                        {
                            result = status != HttpStatusCode.Unauthorized;
                            if (result && login.RememberPassword == true)
                            {
                                Connection.HttpUsername = username;
                                Connection.HttpPassword = password;
                                EventAggregator.GetEvent <ConnectionDetailsChangedEvent>().Publish(new ConnectionDetailsChangedEventArgs(Connection));
                            }
                        }
                    }
                } while (!result);
                break;

            case HttpStatusCode.RequestTimeout:
            {
                var answer = (DisableOption)WindowManager.ShowListInputDialog(Resx.DisableFsdContentScanTriggerTitle, Resx.DisableFsdContentScanTriggerMessage, DisableOption.None, GetDisableOptionList());
                switch (answer)
                {
                case DisableOption.All:
                    UserSettingsProvider.FsdContentScanTrigger = FsdContentScanTrigger.Disabled;
                    break;

                case DisableOption.Single:
                    Connection.IsHttpAccessDisabled = true;
                    break;
                }
            }
            break;
            }
        }
        public override async Task GlobalContext()
        {
            await base.GlobalContext();

            _allQuantities.Add("Organism|Liver|Int|Drug", new Parameter());
        }