示例#1
0
        internal static void AssertNameOnlyValidation(IDataValidator validator, IGroup group)
        {
            ValidationStates results = validator.ValidateNameProperty(group);

            Assert.AreEqual(1, results.Count(), "Group name validation failed");
            Assert.AreEqual(Validations.NAME_PROPERTY, results.First().PropertyName, "Failed property is not a 'Name'");
        }
示例#2
0
        public void DbFavorite_Validate_ReturnsAllProtocolErrors()
        {
            ValidationStates results = ValidateDbFavorite();
            var protocolErrors       = results.Count(result => result.PropertyName == "Protocol");

            Assert.AreEqual(2, protocolErrors, "DbFavorite protocol wasnt validated properly");
        }
示例#3
0
        public void DbFavorite_Validate_ReturnsAllServerNameErrors()
        {
            ValidationStates results = ValidateDbFavorite();
            var serverNameErrors     = results.Count(result => result.PropertyName == "ServerName");

            Assert.AreEqual(2, serverNameErrors, "DbFavorite ServerName wasnt validated properly");
        }
示例#4
0
        private static void LogFavoriteImportError(ValidationStates results, IFavorite favorite)
        {
            var allErrors = results.ToOneMessage();
            var message   = string.Format("Couldnt import invalid favorite: '{0}' because:\r\n{1}", favorite.Name, allErrors);

            Logging.Warn(message);
        }
示例#5
0
 private void UpdateControlsErrorByResults(ValidationStates results)
 {
     // loop through bindings to be able to reset the validaiton state for valid controls
     foreach (KeyValuePair <string, Control> binding in this.validationBindings)
     {
         string message = results[binding.Key];
         this.form.SetErrorInfo(binding.Value, message);
     }
 }
示例#6
0
        /// <summary>
        /// call aditional persistence validation, depending on persistence type.
        /// here we do some validations again, may be considered to be improved.
        /// Returns true, if persistence is satisfied; ohterwise false.
        /// </summary>
        private bool ValidatePersistenceConstraints()
        {
            IFavorite favorite = this.persistence.Factory.CreateFavorite();

            this.form.FillFavoriteFromControls(favorite);
            ValidationStates results = this.validator.Validate(favorite);

            this.UpdateControlsErrorByResults(results);
            bool nameValid = this.ValidateName(favorite);

            // check the results, not the bindings to be able to identify unbound property errors
            return(results.Empty && nameValid);
        }
示例#7
0
        private void TryProcessFavorite(ImportContext context)
        {
            context.ToPerisist = ModelConverterV1ToV2.ConvertToFavorite(context.ToImport, this.persistence, this.connectionManager);
            ValidationStates results = this.validator.Validate(context.ToPerisist);

            if (results.Empty)
            {
                this.ProcessFavorite(context);
            }
            else
            {
                LogFavoriteImportError(results, context.ToPerisist);
            }
        }
 private void UpdateControlsErrorByResults(ValidationStates results)
 {
     // loop through bindings to be able to reset the validaiton state for valid controls
     foreach (KeyValuePair<string, Control> binding in this.validationBindings)
     {
         string message = results[binding.Key];
         this.form.SetErrorInfo(binding.Value, message);
     }
 }
 private static void LogFavoriteImportError(ValidationStates results, IFavorite favorite)
 {
     string allErrors = results.ToOneMessage();
     string message = string.Format("Couldnt import invalid favorite: '{0}' because:\r\n{1}", favorite.Name, allErrors);
     Logging.Warn(message);
 }
示例#10
0
        public void InvalidDbFavorite_Validatie_ReturnsErrorsForAllProperties()
        {
            ValidationStates results = ValidateDbFavorite();

            Assert.AreEqual(9, results.Count(), "Some properties arent validated properly for DbFavorite");
        }