protected override void Context() { _project = new PKSimProject(); _projectRetriever = A.Fake <IProjectRetriever>(); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); _compound1 = A.Fake <Compound>(); _compound1.IsLoaded = false; _compound2 = new Compound { IsLoaded = true }; _compound2.AddProcess(new EnzymaticProcess { MoleculeName = "A", Name = "P1" }); _compound2.AddProcess(new EnzymaticProcess { MoleculeName = "C", Name = "P2" }); _compound2.AddProcess(new EnzymaticProcess { MoleculeName = "B", Name = "P3" }); _individual1 = A.Fake <Individual>(); _individual1.IsLoaded = false; _individual2 = new Individual { IsLoaded = true }; _individual2.AddMolecule(new IndividualEnzyme().WithName("B")); _individual2.AddMolecule(new IndividualEnzyme().WithName("D")); _project.AddBuildingBlock(_compound1); _project.AddBuildingBlock(_compound2); _project.AddBuildingBlock(_individual1); _project.AddBuildingBlock(_individual2); sut = new UsedMoleculeRepository(_projectRetriever); }
protected override void ExecuteWith(IExecutionContext context) { IPKSimProject project = context.CurrentProject; project.RemoveBuildingBlock(_buildingBlockToRemove); Description = PKSimConstants.Command.RemoveEntityFromContainer(ObjectType, _buildingBlockToRemove.Name, context.TypeFor(project), project.Name); //remove results for a simulation. This should be done before serialization removeResultsForSimulation(_buildingBlockToRemove as Simulation); SerializationStream = context.Serialize(_buildingBlockToRemove); context.Unregister(_buildingBlockToRemove); if (!_raiseEvent) { return; } context.PublishEvent(new BuildingBlockRemovedEvent(_buildingBlockToRemove, context.CurrentProject, _dueToSwap)); var simulation = _buildingBlockToRemove as ISimulation; if (simulation != null) { context.PublishEvent(new SimulationRemovedEvent(simulation)); } }
public CreateProjectCommand(IWorkspace workspace, IPKSimProject project) { _workspace = workspace; _project = project; ObjectType = ObjectTypes.Project; CommandType = Command.CommandTypeAdd; }
protected override void Context() { _executionContext = A.Fake <ISBSuiteExecutionContext>(); _entityTask = A.Fake <IEntityTask>(); _eventPublisher = A.Fake <IEventPublisher>(); _project = A.Fake <IPKSimProject>(); _parameterIdentification = new ParameterIdentification(); A.CallTo(() => _executionContext.Project).Returns(_project); A.CallTo(() => _entityTask.NewNameFor(_parameterIdentification, A <IEnumerable <string> > ._, A <string> ._)).Returns("newName"); A.CallTo(() => _project.AllParameterIdentifications).Returns(new[] { new ParameterIdentification() { Name = "name1" }, new ParameterIdentification() { Name = "name2" } }); sut = new RenameParameterIdentificationUICommand(_entityTask, _eventPublisher, _executionContext); sut.For(_parameterIdentification); }
protected override void Context() { _projectRetriever = A.Fake <IPKSimProjectRetriever>(); _registrationTask = A.Fake <IRegistrationTask>(); _eventPublisher = A.Fake <IEventPublisher>(); _lazyLoadTask = A.Fake <ILazyLoadTask>(); _objectTypeResolver = A.Fake <IObjectTypeResolver>(); _buildingBlockRetriever = A.Fake <IBuildingBlockRetriever>(); _buildingBlockVersionUpdater = A.Fake <IBuildingBlockVersionUpdater>(); _projectChangedNotifier = A.Fake <IProjectChangedNotifier>(); _withIdRepository = A.Fake <IWithIdRepository>(); _stringSerializer = A.Fake <ICompressedSerializationManager>(); _cloneManager = A.Fake <ICloner>(); _reportGenerator = A.Fake <IReportGenerator>(); _fullPathDisplayResolver = A.Fake <IFullPathDisplayResolver>(); _project = A.Fake <IPKSimProject>(); _idThatDoesNotExist = "tralalalal"; _parameter = A.Fake <IParameter>(); _parameterChangeUpdater = A.Fake <IParameterChangeUpdater>(); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); _idThatDoesExist = "toto"; _container = A.Fake <IContainer>(); A.CallTo(() => _withIdRepository.ContainsObjectWithId(_idThatDoesExist)).Returns(true); A.CallTo(() => _withIdRepository.Get <IParameter>(_idThatDoesExist)).Returns(_parameter); A.CallTo(() => _withIdRepository.Get(_idThatDoesExist)).Returns(_parameter); A.CallTo(() => _withIdRepository.ContainsObjectWithId(_idThatDoesNotExist)).Returns(false); A.CallTo(() => _withIdRepository.Get(_idThatDoesNotExist)).Throws(new Exception()); sut = new ExecutionContext(_projectRetriever, _withIdRepository, _lazyLoadTask, _registrationTask, _eventPublisher, _objectTypeResolver, _buildingBlockRetriever, _stringSerializer, _buildingBlockVersionUpdater, _projectChangedNotifier, _cloneManager, _container, _reportGenerator, _fullPathDisplayResolver, _parameterChangeUpdater); }
protected override void Context() { base.Context(); _project = A.Fake <IPKSimProject>(); sut.Project = _project; sut.HistoryManager = A.Fake <IHistoryManager>(); }
protected override void Context() { base.Context(); _project = A.Fake <IPKSimProject>(); A.CallTo(() => _eventPublisher.PublishEvent(A <ProjectCreatedEvent> .Ignored)).Invokes( x => _event = x.GetArgument <ProjectCreatedEvent>(0)); }
protected override void Context() { _project = A.Fake <IPKSimProject>(); _entityTask = A.Fake <IEntityTask>(); _templateTaskQuery = A.Fake <ITemplateTaskQuery>(); _executionContext = A.Fake <IExecutionContext>(); A.CallTo(() => _executionContext.CurrentProject).Returns(_project); _applicationController = A.Fake <IApplicationController>(); _buildingBlockInSimulationManager = A.Fake <IBuildingBlockInSimulationManager>(); _buildingBlockRepository = A.Fake <IBuildingBlockRepository>(); _clonePresenter = A.Fake <ICloneBuildingBlockPresenter>(); _renamePresenter = A.Fake <IRenameObjectPresenter>(); _dialogCreator = A.Fake <IDialogCreator>(); _singleStartPresenterTask = A.Fake <ISingleStartPresenterTask>(); _lazyLoadTask = A.Fake <ILazyLoadTask>(); _presenterSettingsTask = A.Fake <IPresentationSettingsTask>(); _simulationReferenceUpdater = A.Fake <ISimulationReferenceUpdater>(); sut = new BuildingBlockTask(_executionContext, _applicationController, _dialogCreator, _buildingBlockInSimulationManager, _entityTask, _templateTaskQuery, _singleStartPresenterTask, _buildingBlockRepository, _lazyLoadTask, _presenterSettingsTask, _simulationReferenceUpdater); A.CallTo(() => _applicationController.Start <ICloneBuildingBlockPresenter>()).Returns(_clonePresenter); A.CallTo(() => _applicationController.Start <IRenameObjectPresenter>()).Returns(_renamePresenter); _buildingBlock = A.Fake <IPKSimBuildingBlock>(); }
public void UpdateProjectAfterSave(IPKSimProject project) { foreach (var simulation in project.All <Simulation>()) { simulation.ResultsHaveChanged = false; } }
protected override void Context() { _applicationController = A.Fake <IApplicationController>(); sut = new CloseSubjectPresenterInvoker(_applicationController); _project = A.Fake <IPKSimProject>(); _buildingBlock = A.Fake <TBuildingBlock>(); }
protected override void Context() { _executionContext = A.Fake <IExecutionContext>(); _buildingBlock = A.Fake <IPKSimBuildingBlock>(); _project = A.Fake <IPKSimProject>(); A.CallTo(() => _executionContext.CurrentProject).Returns(_project); sut = new RemoveBuildingBlockFromProjectCommand(_buildingBlock, _executionContext); }
protected override void Context() { _context = A.Fake <IExecutionContext>(); _oldProtocol = A.Fake <PKSim.Core.Model.Protocol>(); _newProtocol = A.Fake <PKSim.Core.Model.Protocol>(); _project = A.Fake <IPKSimProject>(); A.CallTo(() => _context.CurrentProject).Returns(_project); sut = new SwapProtocolCommand(_oldProtocol, _newProtocol, _context); }
public void UnregisterProject(IPKSimProject project) { if (project == null) { return; } Unregister(project); project.AllObservedData.Each(Unregister); }
public void Visit(IPKSimProject project) { foreach (var observedData in project.AllObservedData) { var baseGrid = observedData.BaseGrid; var baseGridName = baseGrid.Name.Replace(ObjectPath.PATH_DELIMITER, "\\"); baseGrid.QuantityInfo = new QuantityInfo(baseGrid.Name, new[] { observedData.Name, baseGridName }, QuantityType.Time); } }
protected override void Context() { base.Context(); _simulation = A.Fake <Simulation>(); _templateBuildingBlock = A.Fake <IPKSimBuildingBlock>(); _project = A.Fake <IPKSimProject>(); A.CallTo(() => _executionContext.CurrentProject).Returns(_project); _usedBuildingBlock = A.Fake <UsedBuildingBlock>(); A.CallTo(() => _simulationBuildingBlockUpdater.QuickUpdatePossibleFor(_templateBuildingBlock, _usedBuildingBlock)).Returns(false); }
public void LoadProject(string projectFileName, bool isFullPath = false) { var projectFile = isFullPath ? projectFileName : DomainHelperForSpecs.DataFilePathFor($"{projectFileName}.pksim5"); var workspacePersistor = IoC.Resolve <IWorkspacePersistor>(); _workspace = IoC.Resolve <IWorkspace>(); _lazyLoadTask = IoC.Resolve <ILazyLoadTask>(); workspacePersistor.LoadSession(_workspace, projectFile); _project = _workspace.Project; }
protected override void Context() { _projectRetriever = A.Fake <IProjectRetriever>(); _project = A.Fake <IPKSimProject>(); _individual1 = new Individual(); _individual2 = new Individual(); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); A.CallTo(() => _project.All <Individual>()).Returns(new[] { _individual1, _individual2 }); sut = new BuildingBlockRepository(_projectRetriever); }
protected override void Context() { base.Context(); _project = A.Fake <IPKSimProject>(); _templateSettings = A.Fake <OutputSelections>(); A.CallTo(() => _editedSettings.Clone()).Returns(_templateSettings); sut.CreateSettings(_populationSimulation); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); }
protected override void Context() { _populationSimulationSettingsPresenter = A.Fake <IPopulationSimulationSettingsPresenter>(); _applicationController = A.Fake <IApplicationController>(); _projectRetriever = A.Fake <IProjectRetriever>(); _project = A.Fake <IPKSimProject>(); _compound1 = A.Fake <Compound>(); _individual = A.Fake <Individual>(); _human = new Species().WithName(CoreConstants.Species.Human); _rat = new Species().WithName(CoreConstants.Species.Rat); _mouse = new Species().WithName(CoreConstants.Species.Mouse); A.CallTo(() => _individual.Species).Returns(_human); _populationSimulation = A.Fake <PopulationSimulation>(); A.CallTo(() => _populationSimulation.Compounds).Returns(new[] { _compound1 }); A.CallTo(() => _populationSimulation.Individual).Returns(_individual); _keyPathMapper = A.Fake <IKeyPathMapper>(); _entityPathResolver = A.Fake <IEntityPathResolver>(); _userSettings = A.Fake <ICoreUserSettings>(); _originalSettings = new OutputSelections(); A.CallTo(() => _populationSimulation.OutputSelections).Returns(_originalSettings); _populationSimulation.Model = new Model(); _populationSimulation.Model.Root = new Container(); _compound1.Name = "DRUG"; var organism = new Organism(); var peripheralVenousBlood = new Container().WithName(CoreConstants.Organ.PeripheralVenousBlood); var venousBlood = new Container().WithName(CoreConstants.Organ.VenousBlood); var venousBloodPlasma = new Container().WithName(CoreConstants.Compartment.Plasma).WithParentContainer(venousBlood); var drugPeripheralBlood = new Container().WithName(_compound1.Name); var drugVenousBlood = new Container().WithName(_compound1.Name); var periperhalVenousBloodObserver = new Observer { Name = CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD }; drugPeripheralBlood.Add(periperhalVenousBloodObserver); var venousBloodObserver = new Observer { Name = CoreConstants.Observer.CONCENTRATION }; drugVenousBlood.Add(venousBloodObserver); peripheralVenousBlood.Add(drugPeripheralBlood); venousBloodPlasma.Add(drugVenousBlood); organism.Add(peripheralVenousBlood); organism.Add(venousBlood); _populationSimulation.Model.Root.Add(organism); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); A.CallTo(() => _applicationController.Start <ISimulationOutputSelectionPresenter <PopulationSimulation> >()).Returns(_populationSimulationSettingsPresenter); sut = new SimulationSettingsRetriever(_applicationController, _projectRetriever, _entityPathResolver, _keyPathMapper, _userSettings); A.CallTo(() => _entityPathResolver.PathFor(periperhalVenousBloodObserver)).Returns("PERIPHERAL_OBSERVER"); A.CallTo(() => _entityPathResolver.PathFor(venousBloodObserver)).Returns("VENOUS_BLOOD_OBSERVER"); }
protected override void Context() { base.Context(); _fileName = "toto"; _project = A.Fake <IPKSimProject>(); sut.Project = _project; A.CallTo(() => _eventPublisher.PublishEvent(A <ProjectSavingEvent> .Ignored)).Invokes( x => _savingEvent = x.GetArgument <ProjectSavingEvent>(0)); A.CallTo(() => _eventPublisher.PublishEvent(A <ProjectSavedEvent> .Ignored)).Invokes( x => _savedEvent = x.GetArgument <ProjectSavedEvent>(0)); }
protected override void Context() { var workspace = A.Fake <IWorkspace>(); _project = A.Fake <IPKSimProject>(); workspace.Project = _project; A.CallTo(() => _project.AllObservedData).Returns(new List <DataRepository>()); A.CallTo(() => _project.All(PKSimBuildingBlockType.Template)).Returns(_allBuildingBlocks); A.CallTo(() => _project.All <Simulation>()).Returns(new[] { _simulation }); sut = IoC.Resolve <SimulationsReporter>(); }
protected override void Context() { _dialogCreator = A.Fake <IDialogCreator>(); _applicationController = A.Fake <IApplicationController>(); _workspace = A.Fake <IWorkspace>(); _project = A.Fake <IPKSimProject>(); _registrationTask = A.Fake <IRegistrationTask>(); A.CallTo(() => _workspace.Project).Returns(_project); _eventPublisher = A.Fake <IEventPublisher>(); sut = new DeleteSimulationComparisonsUICommand(_applicationController, _workspace, _eventPublisher, _dialogCreator, _registrationTask); _individualSimulationComparison = new IndividualSimulationComparison().WithName("chart"); sut.For(new [] { _individualSimulationComparison }); }
public void Save(IPKSimProject projectToSave, ISession session) { var projectMetaData = projectMetaDataFrom(projectToSave); var projectFromDb = projectFromDatabase(session); if (projectFromDb == null) { saveProject(session, projectMetaData); } else { projectFromDb.UpdateFrom(projectMetaData, session); } }
protected override void Context() { _chartFactory = A.Fake <IPKSimChartFactory>(); _containerTask = A.Fake <IContainerTask>(); _applicationController = A.Fake <IApplicationController>(); _project = new PKSimProject(); _objectBaseFactory = A.Fake <IObjectBaseFactory>(); _singleStartPresenterTask = A.Fake <ISingleStartPresenterTask>(); _executionContext = A.Fake <IExecutionContext>(); _simulationAnalysisCreator = A.Fake <ISimulationAnalysisCreator>(); A.CallTo(() => _executionContext.CurrentProject).Returns(_project); sut = new SimulationComparisonCreator(_chartFactory, _containerTask, _objectBaseFactory, _applicationController, _singleStartPresenterTask, _executionContext, _simulationAnalysisCreator); }
protected override void Context() { _buildingBlockTask = A.Fake <IBuildingBlockTask>(); _executionContext = A.Fake <IExecutionContext>(); _project = A.Fake <IPKSimProject>(); _population = A.Fake <RandomPopulation>(); _randomPopulationPresenter = A.Fake <ICreateRandomPopulationPresenter>(); _applicationController = A.Fake <IApplicationController>(); A.CallTo(() => _applicationController.Start <ICreateRandomPopulationPresenter>()).Returns(_randomPopulationPresenter); A.CallTo(() => _randomPopulationPresenter.BuildingBlock).Returns(_population); A.CallTo(() => _buildingBlockTask.TypeFor(_population)).Returns("pop"); A.CallTo(() => _executionContext.CurrentProject).Returns(_project); sut = new PopulationTask(_executionContext, _buildingBlockTask, _applicationController); }
public void UpdateCompoundInObservedDataFor(IPKSimProject project) { var allProjectCompound = project.All <PKSim.Core.Model.Compound>(); _allAvailableCompounds.AddRange(allProjectCompound); _mapping = new List <ObservedDataToCompoundMappingDTO>(); project.AllObservedData.Each(data => _mapping.Add(mapFrom(data, allProjectCompound))); _view.BindTo(_mapping); _view.Display(); updateMolWeight(); }
protected override void Context() { base.Context(); _project = A.Fake <IPKSimProject>(); _command = A.Fake <IPKSimCommand>(); _simulationToClone = A.Fake <Simulation>().WithName("OLD"); _clonedSimulation = A.Fake <Simulation>().WithName("NEW"); _cloneSimulationPresenter = A.Fake <ICloneSimulationPresenter>(); A.CallTo(() => _applicationController.Start <ICloneSimulationPresenter>()).Returns(_cloneSimulationPresenter); A.CallTo(() => _executionContext.CurrentProject).Returns(_project); A.CallTo(() => _cloneSimulationPresenter.CloneSimulation(_simulationToClone)).Returns(_command); A.CallTo(() => _cloneSimulationPresenter.Simulation).Returns(_clonedSimulation); A.CallTo(() => _buildingBlockInSimulationManager.StatusFor(_simulationToClone)).Returns(BuildingBlockStatus.Green); }
public ProjectMetaData MapFrom(IPKSimProject project) { var projectMetaData = new ProjectMetaData(); project.All <IPKSimBuildingBlock>().Each(x => projectMetaData.AddBuildingBlock(mapFrom(x))); project.AllSimulationComparisons.Each(x => projectMetaData.AddSimulationComparison(mapFrom(x))); project.AllParameterIdentifications.Each(x => projectMetaData.AddParameterIdentification(mapFrom(x))); project.AllSensitivityAnalyses.Each(x => projectMetaData.AddSensitivityAnalysis(mapFrom(x))); project.AllObservedData.Each(x => projectMetaData.AddObservedData(mapFrom(x))); projectMetaData.Name = project.Name; projectMetaData.Description = project.Description; projectMetaData.Content.Data = _serializationManager.Serialize(project); _metaData = null; return(projectMetaData); }
protected override void Context() { _pkmlFile = "file"; _project = new PKSimProject(); _dimensionFactory = A.Fake <IDimensionFactory>(); _objectBaseFactory = A.Fake <IObjectBaseFactory>(); _simulationPersister = A.Fake <ISimulationPersistor>(); _projectRetriever = A.Fake <IProjectRetriever>(); _dialogCreator = A.Fake <IDialogCreator>(); _journalTask = A.Fake <IJournalTask>(); _cloneManagerForModel = A.Fake <ICloneManagerForModel>(); sut = new SimulationTransferLoader(_dimensionFactory, _objectBaseFactory, _simulationPersister, _projectRetriever, _dialogCreator, _journalTask, _cloneManagerForModel); _simulationTransfer = new SimulationTransfer(); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); A.CallTo(() => _simulationPersister.Load(_pkmlFile, _dimensionFactory, _objectBaseFactory, A <IWithIdRepository> ._, _cloneManagerForModel)).Returns(_simulationTransfer); }
protected override void Context() { _context = A.Fake <IExecutionContext>(); _oldSimulation = A.Fake <Simulation>(); _newSimulation = A.Fake <Simulation>(); _project = A.Fake <IPKSimProject>(); _simulationDifferenceBuilder = A.Fake <ISimulationCommandDescriptionBuilder>(); _simulationReferenceUpdater = A.Fake <ISimulationReferenceUpdater>(); A.CallTo(() => _context.CurrentProject).Returns(_project); A.CallTo(() => _context.Resolve <ISimulationCommandDescriptionBuilder>()).Returns(_simulationDifferenceBuilder); A.CallTo(() => _context.Resolve <ISimulationReferenceUpdater>()).Returns(_simulationReferenceUpdater); var reportPart = new ReportPart(); reportPart.AddToContent("toto"); A.CallTo(() => _simulationDifferenceBuilder.BuildDifferenceBetween(_oldSimulation, _newSimulation)).Returns(reportPart); sut = new SwapSimulationCommand(_oldSimulation, _newSimulation, _context); }