Example #1
0
        public void NegatedFailureWithStringUpper()
        {
            RangeValidator validator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null, true);

            Assert.IsFalse(validator.Validate("cccc").IsValid);
            Assert.IsFalse(validator.Validate("dddd").IsValid);
        }
Example #2
0
        public void NonNegatedSuccessWithStringUpper()
        {
            RangeValidator validator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null);

            Assert.IsTrue(validator.Validate("cccc").IsValid);
            Assert.IsTrue(validator.Validate("dddd").IsValid);
        }
Example #3
0
        public void NegatedFailureWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null, true);

            Assert.IsFalse(inclusiveValidator.Validate("cccc").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("cccca").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("gggg").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("rrrr").IsValid);
        }
Example #4
0
        public void NonNegatedSuccessWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null);

            Assert.IsTrue(inclusiveValidator.Validate("cccc").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("cccca").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("gggg").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("rrrr").IsValid);
        }
Example #5
0
        public void NonNegatedFailureWithStringUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null);

            Assert.IsFalse(inclusiveValidator.Validate("bbbb").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, null, RangeBoundaryType.Ignore, null);

            Assert.IsFalse(exclusiveValidator.Validate("bbbb").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("cccc").IsValid);
        }
Example #6
0
        public void NegatedSuccessWithStringUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null, true);

            Assert.IsTrue(inclusiveValidator.Validate("bbbb").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, null, RangeBoundaryType.Ignore, null, true);

            Assert.IsTrue(exclusiveValidator.Validate("bbbb").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("cccc").IsValid);
        }
Example #7
0
    private bool IsGridViewValid()
    {
        bool hasCheckBoxSelected = false;

        foreach (GridViewRow row in uxProductReturnGrid.Rows)
        {
            if (row.FindControl("uxSelectBox") != null)
            {
                CheckBox box = (CheckBox)row.FindControl("uxSelectBox");

                if (box.Checked)
                {
                    hasCheckBoxSelected = true;
                    TextBox        text  = (TextBox)row.FindControl("uxQuantityText");
                    RangeValidator range = (RangeValidator)row.FindControl("uxQuantityRange");

                    if (String.IsNullOrEmpty(text.Text))
                    {
                        range.IsValid = false;
                    }
                    else
                    {
                        range.Validate();
                    }
                }
            }
        }

        return(hasCheckBoxSelected);
    }
Example #8
0
        public void ShouldReturnFalseForString()
        {
            string    testValue      = "Some text";
            Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue);

            Assert.IsFalse(rangeValidator.Validate());
        }
        /// <summary>
        /// Valida se as frequencias lançadas estão no intervalo correto (Percorre o repeater)
        /// </summary>
        /// <returns>True caso as frequencias estejam corretas</returns>
        private bool ValidaFrequencias()
        {
            for (int i = 0; i < rptAlunosFrequencia.Items.Count; i++)
            {
                Repeater rptAulas = (Repeater)rptAlunosFrequencia.FindControl("rptAulas");

                if (rptAulas != null)
                {
                    for (int j = 0; j < rptAulas.Items.Count; j++)
                    {
                        RangeValidator rvFreq = (RangeValidator)rptAulas.Items[j].FindControl("rvFreq");
                        if (rvFreq != null)
                        {
                            rvFreq.Validate();
                            if (!rvFreq.IsValid)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Example #10
0
        public void ShouldReturnTrueForDecimalValue()
        {
            decimal   testValue      = 2;
            Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue);

            Assert.IsTrue(rangeValidator.Validate());
        }
Example #11
0
        public void ShouldReturnFalseForDoubleValueIncluded()
        {
            double    testValue      = 10;
            Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue);

            Assert.IsFalse(rangeValidator.Validate());
        }
Example #12
0
        public void ShouldReturnFalseForIntValue()
        {
            int       testValue      = 12;
            Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue);

            Assert.IsFalse(rangeValidator.Validate());
        }
Example #13
0
        public void ShouldReturnTrueForIntValueIncluded()
        {
            int       testValue      = 10;
            Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue, true);

            Assert.IsTrue(rangeValidator.Validate());
        }
Example #14
0
        public void NonNegatedRejectsNull()
        {
            RangeValidator validator = new RangeValidator(2);

            ValidationResults results = validator.Validate(null);

            Assert.IsFalse(results.IsValid);
        }
Example #15
0
        public void ReturnsSuccessForValueInRange()
        {
            Validator <string> validator = new RangeValidator <string>("aaaa", RangeBoundaryType.Exclusive, "zzzz", RangeBoundaryType.Inclusive);

            ValidationResults validationResults = validator.Validate("bbbb");

            Assert.IsTrue(validationResults.IsValid);
        }
Example #16
0
        public void NonNegatedRejectsNullForValueType()
        {
            Validator <int> validator = new RangeValidator <int>(0, RangeBoundaryType.Inclusive, 2, RangeBoundaryType.Inclusive, "test");

            ValidationResults results = validator.Validate(null);

            Assert.IsFalse(results.IsValid);
        }
        public void ReturnsSuccessForValueInRange()
        {
            Validator<string> validator = new RangeValidator<string>("aaaa", RangeBoundaryType.Exclusive, "zzzz", RangeBoundaryType.Inclusive);

            ValidationResults validationResults = validator.Validate("bbbb");

            Assert.IsTrue(validationResults.IsValid);
        }
        public void NonNegatedRejectsNull()
        {
            RangeValidator validator = new RangeValidator(2);

            ValidationResults results = validator.Validate(null);

            Assert.IsFalse(results.IsValid);
        }
Example #19
0
        public void NonNegatedRejectsNullForReferenceType()
        {
            Validator <string> validator = new RangeValidator <string>("aaaa", RangeBoundaryType.Inclusive, "bbbb", RangeBoundaryType.Inclusive, "test");

            ValidationResults results = validator.Validate(null);

            Assert.IsFalse(results.IsValid);
        }
Example #20
0
        public void NegatedSuccessWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null, true);

            Assert.IsTrue(inclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("zzzz").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, "rrrr", RangeBoundaryType.Exclusive, null, true);

            Assert.IsTrue(exclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("cccc").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("rrrr").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("zzzz").IsValid);
        }
            protected override void DoValidate(decimal?objectToValidate, object currentTarget, string key, ValidationResults validationResults)
            {
                if (objectToValidate == null)
                {
                    return;
                }

                validationResults.AddAllResults(_innerValidator.Validate(objectToValidate.Value));
            }
Example #22
0
        public void NonNegatedFailureWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null);

            Assert.IsFalse(inclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("zzzz").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, "rrrr", RangeBoundaryType.Exclusive, null);

            Assert.IsFalse(exclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("cccc").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("rrrr").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("zzzz").IsValid);
        }
Example #23
0
        public void ReturnsFailureForValueOutsideRange()
        {
            Validator <string> validator = new RangeValidator <string>("aaaa", RangeBoundaryType.Exclusive, "zzzz", RangeBoundaryType.Inclusive);

            ValidationResults validationResults = validator.Validate("0000");

            Assert.IsFalse(validationResults.IsValid);
            IList <ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);

            Assert.AreEqual(1, resultsList.Count);
            Assert.IsTrue(TemplateStringTester.IsMatch(Resources.RangeValidatorNonNegatedDefaultMessageTemplate, resultsList[0].Message));
        }
Example #24
0
        // TODO fix with templated message.
        public void ReturnsFailureWithOverridenMessageForValueOutsideRange()
        {
            string message = "overrinde message";

            Validator <string> validator = new RangeValidator <string>("aaaa", RangeBoundaryType.Exclusive, "zzzz", RangeBoundaryType.Inclusive, message);

            ValidationResults validationResults = validator.Validate("0000");

            Assert.IsFalse(validationResults.IsValid);
            IList <ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);

            Assert.AreEqual(1, resultsList.Count);
            Assert.AreEqual(message, resultsList[0].Message);
        }
Example #25
0
        /// <summary>
        /// When overridden in a derived class, this method contains the code to determine whether the value in the input control is valid.
        /// </summary>
        /// <returns>
        /// true if the value in the input control is valid; otherwise, false.
        /// </returns>
        protected override bool EvaluateIsValid()
        {
            if (this.rangeValidator != null)
            {
                rangeValidator.Validate();
                if (!this.rangeValidator.IsValid)
                {
                    return(false);
                }
            }

            if (this.requiredFieldValidator != null)
            {
                requiredFieldValidator.Validate();
                if (!this.requiredFieldValidator.IsValid)
                {
                    return(false);
                }
            }

            if (this.compareValidator != null)
            {
                compareValidator.Validate();
                if (!this.compareValidator.IsValid)
                {
                    return(false);
                }
            }

            if (this.regularExpressionValidator != null)
            {
                regularExpressionValidator.Validate();
                if (!this.regularExpressionValidator.IsValid)
                {
                    return(false);
                }
            }

            if (this.customStringLengthValidator != null)
            {
                customStringLengthValidator.Validate();
                if (!this.customStringLengthValidator.IsValid)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #26
0
        public override void Validate()
        {
            string valClientId = null;

            if (!ReadOnly)
            {
                base.Validate();
                IsValid     = RequiredFieldValidator.IsValid;
                valClientId = RequiredFieldValidator.ClientID;
            }

            if (RangeValidationEnabled)
            {
                if (IsValid)
                {
                    m_RangeValidator.Validate();
                    IsValid     = m_RangeValidator.IsValid;
                    valClientId = m_RangeValidator.ClientID;
                }
            }

            if (RegularExpressionValidationEnabled)
            {
                if (IsValid)
                {
                    m_RegularExpressionValidator.Validate();
                    IsValid     = m_RegularExpressionValidator.IsValid;
                    valClientId = m_RegularExpressionValidator.ClientID;
                }
            }

            if (this.Theme == MasterPageTheme.Modern)
            {
                if (!IsValid)
                {
                    this.CssClass += " Invalid";
                    this.Attributes["validatorId"] = valClientId;
                }
            }
        }
Example #27
0
        public List <CustomerModel> showMyCustomers(int engineerid)
        {
            List <CustomerModel> clist = null;

            try
            {
                Validator <int>   eidvalidator = new RangeValidator <int>(0, RangeBoundaryType.Inclusive, Int32.MaxValue, RangeBoundaryType.Exclusive);
                ValidationResults vresult      = eidvalidator.Validate(engineerid);
                if (!vresult.IsValid)
                {
                    log.Warn("Engineerid muss positiv sein.");
                    throw new BLException("Engineerid muss positiv sein.");
                }
                clist = erepo.GetMyCustomers(engineerid);
                log.Info("Kunden des Technikers wurden abgerufen.");
            }
            catch (DalException exp)
            {
                log.Error("Kunden des Technikers konnten nicht abgerufen werden.");
                throw new BLException("Kunden des Technikers konnten nicht abgerufen werden.", exp);
            }
            return(clist);
        }
Example #28
0
        public void ShouldReturnTrueForRangeValidatableObject()
        {
            Validator rangeValidator = new RangeValidator(trueObject, minValue, maxValue);

            Assert.IsTrue(rangeValidator.Validate());
        }
        public void NonNegatedRejectsNullForValueType()
        {
            Validator<int> validator = new RangeValidator<int>(0, RangeBoundaryType.Inclusive, 2, RangeBoundaryType.Inclusive, "test");

            ValidationResults results = validator.Validate(null);

            Assert.IsFalse(results.IsValid);
        }
        public void NonNegatedRejectsNullForReferenceType()
        {
            Validator<string> validator = new RangeValidator<string>("aaaa", RangeBoundaryType.Inclusive, "bbbb", RangeBoundaryType.Inclusive, "test");

            ValidationResults results = validator.Validate(null);

            Assert.IsFalse(results.IsValid);
        }
        // TODO fix with templated message.
        public void ReturnsFailureWithOverridenMessageForValueOutsideRange()
        {
            string message = "overrinde message";

            Validator<string> validator = new RangeValidator<string>("aaaa", RangeBoundaryType.Exclusive, "zzzz", RangeBoundaryType.Inclusive, message);

            ValidationResults validationResults = validator.Validate("0000");

            Assert.IsFalse(validationResults.IsValid);
            IList<ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);
            Assert.AreEqual(1, resultsList.Count);
            Assert.AreEqual(message, resultsList[0].Message);
        }
Example #32
0
        public void ShouldReturnFalseForRangeValidatableObject()
        {
            Validator rangeValidator = new RangeValidator(falseObject, minValue, maxValue);

            Assert.IsFalse(rangeValidator.Validate());
        }
        public void NegatedSuccessWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null, true);

            Assert.IsTrue(inclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("zzzz").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, "rrrr", RangeBoundaryType.Exclusive, null, true);

            Assert.IsTrue(exclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("cccc").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("rrrr").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("zzzz").IsValid);
        }
        public void NegatedFailureWithStringUpper()
        {
            RangeValidator validator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null, true);

            Assert.IsFalse(validator.Validate("cccc").IsValid);
            Assert.IsFalse(validator.Validate("dddd").IsValid);
        }
        public void NonNegatedFailureWithStringUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null);

            Assert.IsFalse(inclusiveValidator.Validate("bbbb").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, null, RangeBoundaryType.Ignore, null);

            Assert.IsFalse(exclusiveValidator.Validate("bbbb").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("cccc").IsValid);
        }
        public void NegatedFailureWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null, true);

            Assert.IsFalse(inclusiveValidator.Validate("cccc").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("cccca").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("gggg").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("rrrr").IsValid);
        }
        public void NonNegatedSuccessWithStringUpper()
        {
            RangeValidator validator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null);

            Assert.IsTrue(validator.Validate("cccc").IsValid);
            Assert.IsTrue(validator.Validate("dddd").IsValid);
        }
        public void NonNegatedFailureWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null);

            Assert.IsFalse(inclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsFalse(inclusiveValidator.Validate("zzzz").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, "rrrr", RangeBoundaryType.Exclusive, null);

            Assert.IsFalse(exclusiveValidator.Validate("aaaa").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("cccc").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("bcccc").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("rrrra").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("rrrr").IsValid);
            Assert.IsFalse(exclusiveValidator.Validate("zzzz").IsValid);
        }
        public void NonNegatedSuccessWithStringBeetweenLowerAndUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, "rrrr", RangeBoundaryType.Inclusive, null);

            Assert.IsTrue(inclusiveValidator.Validate("cccc").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("cccca").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("gggg").IsValid);
            Assert.IsTrue(inclusiveValidator.Validate("rrrr").IsValid);
        }
        public void ReturnsFailureForValueOutsideRange()
        {
            Validator<string> validator = new RangeValidator<string>("aaaa", RangeBoundaryType.Exclusive, "zzzz", RangeBoundaryType.Inclusive);

            ValidationResults validationResults = validator.Validate("0000");

            Assert.IsFalse(validationResults.IsValid);
            IList<ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);
            Assert.AreEqual(1, resultsList.Count);
            Assert.IsTrue(TemplateStringTester.IsMatch(Resources.RangeValidatorNonNegatedDefaultMessageTemplate, resultsList[0].Message));
        }
        public void NegatedSuccessWithStringUpper()
        {
            RangeValidator inclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Inclusive, null, RangeBoundaryType.Ignore, null, true);

            Assert.IsTrue(inclusiveValidator.Validate("bbbb").IsValid);

            RangeValidator exclusiveValidator = new RangeValidator("cccc", RangeBoundaryType.Exclusive, null, RangeBoundaryType.Ignore, null, true);

            Assert.IsTrue(exclusiveValidator.Validate("bbbb").IsValid);
            Assert.IsTrue(exclusiveValidator.Validate("cccc").IsValid);
        }
 public List<CustomerModel> showMyCustomers(int engineerid)
 {
     List<CustomerModel> clist = null;
     try
     {
         Validator<int> eidvalidator = new RangeValidator<int>(0, RangeBoundaryType.Inclusive, Int32.MaxValue, RangeBoundaryType.Exclusive);
         ValidationResults vresult = eidvalidator.Validate(engineerid);
         if (!vresult.IsValid)
         {
             log.Warn("Engineerid muss positiv sein.");
             throw new BLException("Engineerid muss positiv sein.");
         }
         clist = erepo.GetMyCustomers(engineerid);
         log.Info("Kunden des Technikers wurden abgerufen.");
     }
     catch (DalException exp)
     {
         log.Error("Kunden des Technikers konnten nicht abgerufen werden.");
         throw new BLException("Kunden des Technikers konnten nicht abgerufen werden.", exp);
     }
     return clist;
 }
Example #43
0
        /// <summary>
        /// The method validates whether a supplied object is within range defined by minimum and maximum limits.
        /// </summary>
        /// <param name="objectToValidate">An object to be valdiated.</param>
        /// <param name="minValue">A minimum valid limit.</param>
        /// <param name="maxValue">A maximum valid limit.</param>
        /// <param name="includeLimits"></param>
        /// <returns>True - if object is valid, false - if object is invalid.</returns>
        public static bool IsWithinRange(object objectToValidate, decimal minValue, decimal maxValue, bool includeLimits)
        {
            Validator validator = new RangeValidator(objectToValidate, minValue, maxValue, includeLimits);

            return(validator.Validate());
        }