private void GivenTheValidationSucceeds()
        {
            var ok       = new ConfigurationValidationResult(false);
            var response = new OkResponse <ConfigurationValidationResult>(ok);

            _validator.Setup(x => x.IsValid(It.IsAny <FileConfiguration>())).ReturnsAsync(response);
        }
Example #2
0
        public static ILogger <TDataItem> Validate <TDataItem>(this ILogger <TDataItem> logger, IKernel kernel)
        {
            ILoggerInternal loggerInternal = logger as ILoggerInternal;

            if (loggerInternal == null)
            {
                throw new ArgumentException("logger must implement ILoggerInternal");
            }

            ConfigurationValidationResult result = new ConfigurationValidationResult();

            if (!InterceptionEnabled(kernel))
            {
                result.AddError("Castle binding not set. Call BindToWindsor method.");
            }

            ConfigurationValidationResult innerValidationResult = ((ILoggerInternal)logger).ValidateConfiguration(
                new DeclaringTypeMustBeAccessibleForProxyCreating(),
                new DeclaringTypeCannotBeOpenGeneric(),
                new DeclaringTypeCannotBeInterface(),
                new ReturnsSatisfiedIfUnableToCheck(
                    new MethodMustBeVirtualIfDeclaringTypeRegisteredOnlyForItself(kernel)),
                new DeclaringTypeMustBeRegisteredInContainer(kernel),
                new ReturnsSatisfiedIfUnableToCheck(
                    new DeclaringNonGenericTypeMustBeRegisteredInContainerAfterLoggerConfigured(kernel)));

            result.CopyErrorsFrom(innerValidationResult);

            if (!result.IsValid)
            {
                throw new LoggerValidationException(result);
            }

            return(logger);
        }
Example #3
0
        public ConfigurationValidationResult ValidateConfiguration(params IMethodInfoRequirement[] methodRequirements)
        {
            var result = new ConfigurationValidationResult();

            _loggers.ForEach(l => result.CopyErrorsFrom(l.ValidateConfiguration(methodRequirements)));
            return(result);
        }
        private void GivenTheValidationFails()
        {
            var error = new ConfigurationValidationResult(true, new List <Error> {
                new AnyError()
            });
            var response = new OkResponse <ConfigurationValidationResult>(error);

            _validator.Setup(x => x.IsValid(It.IsAny <FileConfiguration>())).ReturnsAsync(response);
        }
Example #5
0
        public ConfigurationValidationResult ValidateConfiguration()
        {
            ConfigurationValidationResult validationResult = new ConfigurationValidationResult();

            if (String.IsNullOrEmpty(ConnectionString))
            {
                validationResult.Errors.Add("Connectionstring must not be empty!");
            }

            return(validationResult);
        }
Example #6
0
        public ConfigurationValidationResult ValidateConfiguration()
        {
            ConfigurationValidationResult validationResult = new ConfigurationValidationResult();

            if (String.IsNullOrEmpty(FilePath))
            {
                validationResult.Errors.Add("Filepath must not be empty!");
            }

            if (String.IsNullOrEmpty(SheetName))
            {
                validationResult.Errors.Add("SheetName must not be empty!");
            }

            return(validationResult);
        }
        public ConfigurationValidationResult ValidateConfiguration()
        {
            ConfigurationValidationResult validationResult = new ConfigurationValidationResult();

            switch (QueryType)
            {
            case SQLiteQueryType.SqlQuery:
                if (String.IsNullOrEmpty(SqlValue))
                {
                    validationResult.Errors.Add("SQL Query must not be empty!");
                }
                break;
            }

            return(validationResult);
        }
        /// <summary>
        /// Validate service configurations
        /// </summary>
        /// <param name="config">Settings to validate</param>
        /// <returns>Validation result</returns>
        public ConfigurationValidationResult ValidateConfiguration(ServiceHostConfiguration config)
        {
            var result        = new ConfigurationValidationResult();
            var configResults = ValidateEntity(config);

            foreach (var configResult in configResults)
            {
                result.AddError(configResult.Message);
            }

            foreach (var entity in config.Services)
            {
                var results = ValidateEntity(entity);

                if (!results.IsValid)
                {
                    var messages = results.Select(x => x.Message).ToList();
                    result.AddEntity(entity, messages);
                }
            }

            return(result);
        }
 public ConfigurationSchemaViolationException(ConfigurationValidationResult configResult)
 {
     ConfigurationValidationResult = configResult;
 }
Example #10
0
 public LoggerValidationException(ConfigurationValidationResult validationResult)
     : base("Logger is invalid.\n " + validationResult)
 {
     ValidationResult = validationResult;
 }