Base class for all Service configuration entities.
Inheritance: BaseEntity
 public void AddEntity(BaseServiceEntity entity, IEnumerable<string> messages) {
     if(!invalidEntities.ContainsKey(entity)) {
         invalidEntities.Add(entity, new List<string>());
     }
     
     foreach(var message in messages) {
         invalidEntities[entity].Add(message);    
     }
 }
        public void ServiceDependencyValidationFailureTest()
        {
            P4ServiceEntity entity = new P4ServiceEntity();
            IEnumerable<BaseServiceEntity> entities = new BaseServiceEntity[] {
                entity,
            };

            settings = new ServiceHostConfiguration(entities);
            validator.CheckOtherServiceDependency(entity, settings);
        }
        public void ServiceDependencyValidationSuccessTest()
        {
            P4ServiceEntity entity = new P4ServiceEntity();
            ChangesetWriterEntity writerEntity = new ChangesetWriterEntity();
            IList<BaseServiceEntity> entities = new BaseServiceEntity[] {
                entity, writerEntity,
            };

            settings = new ServiceHostConfiguration(entities);
            validator.CheckOtherServiceDependency(entity, settings);
        }
        /// <summary>
        /// Throw exception if entity depends on other entity that is missing.
        /// </summary>
        /// <param name="entity">entity to validate</param>
        /// <param name="config">Service Host configuration container</param>
        /// <exception cref="DependencyFailureException" />
        public void CheckOtherServiceDependency(BaseServiceEntity entity, ServiceHostConfiguration config) {
            var attributes = entity.GetType().GetCustomAttributes(typeof (DependsOnServiceAttribute), false);
            
            if(attributes.Length < 1) {
                return;
            }

            foreach(var attribute in attributes.Cast<DependsOnServiceAttribute>().Where(attribute => config[attribute.ServiceType] == null)) {
                throw new DependencyFailureException(attribute.ServiceType, "Service dependency does not exist");
            }
        }
        public IConnectionValidator CreateValidator(BaseServiceEntity entity) {
            var entityType = entity.GetType();

            if(!entityToValidatorTypeMappings.ContainsKey(entityType)) {
                throw new NotSupportedException("Wrong entity type");
            }

            var validatorType = entityToValidatorTypeMappings[entityType];
            var validator = (IConnectionValidator) Activator.CreateInstance(validatorType, new object[] { entity });

            return validator;
        }
        public void ServiceDependenciesValidationFailureTest()
        {
            P4ServiceEntity p4Entity = new P4ServiceEntity();
            ChangesetWriterEntity writerEntity = new ChangesetWriterEntity();
            FitnesseServiceEntity fitEntity = new FitnesseServiceEntity();
            IList<BaseServiceEntity> entities = new BaseServiceEntity[] {
                p4Entity, writerEntity, fitEntity,
            };

            settings = new ServiceHostConfiguration(entities);
            validator.CheckServiceDependencies(settings);
        }
        private static ServiceHostConfiguration CreateConfiguration()
        {
            var services = new BaseServiceEntity[] {
                new P4ServiceEntity(),
                new SvnServiceEntity(),
                new BugzillaServiceEntity(),
                new ChangesetWriterEntity(),
                new WorkitemWriterEntity(),
            };

            return new ServiceHostConfiguration(services);
        }
        public void AddService(BaseServiceEntity entity) {
            if(entity is IVersionOneSettingsConsumer) {
                var settingsConsumer = (IVersionOneSettingsConsumer) entity;

                if(Settings != null) {
                    settingsConsumer.Settings = Settings;
                } else {
                    Settings = settingsConsumer.Settings;
                    ProxySettings = settingsConsumer.Settings.ProxySettings;
                }
            }
            
            services.Add(entity);
        }
Beispiel #9
0
        public void AddService(BaseServiceEntity entity)
        {
            if (entity is IVersionOneSettingsConsumer)
            {
                var settingsConsumer = (IVersionOneSettingsConsumer)entity;

                if (Settings != null)
                {
                    settingsConsumer.Settings = Settings;
                }
                else
                {
                    Settings      = settingsConsumer.Settings;
                    ProxySettings = settingsConsumer.Settings.ProxySettings;
                }
            }

            services.Add(entity);
        }
        private string GetInvalidPageErrorMessage(BaseServiceEntity entity, IEnumerable<string> messages)
        {
            var pageName = uiFactory.ResolvePageNameByEntity(entity);

            return string.Format("{0} page contains invalid data:{1}{2}{3}", pageName, Environment.NewLine, "-", string.Join(Environment.NewLine + "-", messages.ToArray()));
        }
 /// <summary>
 /// Throw exception if entity requires connection to V1 and actual connection is down.
 /// </summary>
 /// <param name="entity">entity to validate</param>
 /// <exception cref="V1ConnectionRequiredException"/>
 public void CheckVersionOneDependency(BaseServiceEntity entity) {
     if(entity.GetType().IsDefined(typeof(DependsOnVersionOneAttribute), false) && !facade.IsConnected) {
         throw new V1ConnectionRequiredException();
     }
 }