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); }
public TBuildingBlock BuildingBlockWithId <TBuildingBlock>(string buildingBlockId) where TBuildingBlock : class, IPKSimBuildingBlock { if (_withIdRepository.ContainsObjectWithId(buildingBlockId)) { return(_withIdRepository.Get <IPKSimBuildingBlock>(buildingBlockId) as TBuildingBlock); } return(null); }
public string GetEntityName(string id) { if (!_withIdRepository.ContainsObjectWithId(id)) { return(id); } var entity = _withIdRepository.Get <IObjectBase>(id); return(entity.Name); }
private IPKSimBuildingBlock subjectFor(WorkspaceLayoutItem layoutItem) { if (!_withIdRepository.ContainsObjectWithId(layoutItem.SubjectId)) { return(null); } var subject = _withIdRepository.Get <IPKSimBuildingBlock>(layoutItem.SubjectId); _lazyLoadTask.Load(subject); return(subject); }
private CompoundProperties compoundPropertiesFor(IReadOnlyList <IParameter> allParameters) { if (!allParameters.Any()) { return(null); } var firstParameter = allParameters[0]; var compoundName = firstParameter.ParentContainer.Name; var simulation = _withIdRepository.Get <Simulation>(firstParameter.Origin.SimulationId); return(simulation?.CompoundPropertiesList.FirstOrDefault(x => x.Compound.IsNamed(compoundName))); }
public IWithId Get(string id) { if (!_withIdRepository.ContainsObjectWithId(id)) { return(null); } var entity = _withIdRepository.Get(id); if (entity == null) { return(null); } Load(entity as ILazyLoadable); return(entity); }
public static void AddReferencedObject <TObectWithReference, TReference>(this XElement referenceElementList, TObectWithReference objectWithReference, Func <TObectWithReference, Action <TReference> > addAction, IWithIdRepository withIdRepository, ILazyLoadTask lazyLoadTask, string referenceElementName) where TReference : class, IWithId { foreach (var referenceElement in referenceElementList.Descendants(referenceElementName)) { var id = referenceElement.GetAttribute(Constants.Serialization.Attribute.ID); //reference might have been deleted...in that case, simply ignore the simulation if (!withIdRepository.ContainsObjectWithId(id)) { continue; } var reference = withIdRepository.Get <TReference>(id); var lazyLoadable = reference as ILazyLoadable; if (lazyLoadable != null) { lazyLoadTask?.Load(lazyLoadable); } addAction(objectWithReference)(reference); } }
private Simulation simulationFrom(IReadOnlyList <IParameter> allParameters) { var firstParameter = allParameters[0]; return(_withIdRepository.Get <Simulation>(firstParameter.Origin.SimulationId)); }
public void ResolveReferences() { _ids.Each(id => _cache.Add(_withIdRepository.Get <DataColumn>(id))); }
private ISimulation simulationContaining(IParameter parameter) { return(_withIdRepository.Get <ISimulation>(parameter.Origin.SimulationId)); }
protected override IWithId RetrieveSubjectFor(IClassifiableWrapper classifiableWrapper, IProject project) { return(_withIdRepository.Get(classifiableWrapper.Id)); }