Example #1
0
        public RenameObjectDTO CreateFor(IWithName objectBase)
        {
            //Entity might be a building block in disguise!
            var buildingBlock = objectBase as IPKSimBuildingBlock;

            if (buildingBlock != null)
            {
                return(createFor(buildingBlock));
            }

            var parameterAnalyzable = objectBase as IParameterAnalysable;

            if (parameterAnalyzable != null)
            {
                return(createFor(parameterAnalyzable));
            }

            var dto = new RenameObjectDTO(objectBase.Name);

            var entity = objectBase as IEntity;

            if (entity?.ParentContainer == null)
            {
                return(dto);
            }

            dto.ContainerType = _objectTypeResolver.TypeFor(entity.ParentContainer);
            dto.AddUsedNames(entity.ParentContainer.AllChildrenNames());

            return(dto);
        }
Example #2
0
        private RenameObjectDTO createRenameInProjectDTO(IWithName withName, IEnumerable <IWithName> existingObjects)
        {
            var dto = new RenameObjectDTO(withName.Name)
            {
                ContainerType = PKSimConstants.ObjectTypes.Project
            };

            dto.AddUsedNames(existingObjects.AllNames());
            return(dto);
        }
        protected override void Context()
        {
            _applicationController = A.Fake <IApplicationController>();
            _executionContext      = A.Fake <IExecutionContext>();
            _entity = A.Fake <IEntity>();
            _renameObjectFactory = A.Fake <IRenameObjectDTOFactory>();
            _renamePresenter     = A.Fake <IRenameObjectPresenter>();
            A.CallTo(() => _applicationController.Start <IRenameObjectPresenter>()).Returns(_renamePresenter);
            sut = new EntityTask(_applicationController, _executionContext, _renameObjectFactory);

            _renameDTO = new RenameObjectDTO(_entity.Name);
            _renameDTO.AddUsedNames(new[] { "A", "B" });
            A.CallTo(() => _renameObjectFactory.CreateFor(_entity)).Returns(_renameDTO);
            A.CallTo(() => _executionContext.TypeFor <IObjectBase>(_entity)).Returns(ENT_TYPE);
        }
Example #4
0
        public RenameObjectDTO CreateFor(IWithName objectBase)
        {
            var dto = new RenameObjectDTO(objectBase.Name);

            var entity = objectBase as IEntity;

            if (entity == null || entity.ParentContainer == null)
            {
                return(dto);
            }

            dto.ContainerType = _objectTypeResolver.TypeFor(entity.ParentContainer);
            dto.AddUsedNames(entity.ParentContainer.AllChildrenNames());

            return(dto);
        }