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 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 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 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 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 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); }
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); }
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); }
public void ShouldReturnTrueForDecimalValue() { decimal testValue = 2; Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue); Assert.IsTrue(rangeValidator.Validate()); }
public void ShouldReturnFalseForDoubleValueIncluded() { double testValue = 10; Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue); Assert.IsFalse(rangeValidator.Validate()); }
public void ShouldReturnFalseForIntValue() { int testValue = 12; Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue); Assert.IsFalse(rangeValidator.Validate()); }
public void ShouldReturnTrueForIntValueIncluded() { int testValue = 10; Validator rangeValidator = new RangeValidator(testValue, minValue, maxValue, true); Assert.IsTrue(rangeValidator.Validate()); }
public void NonNegatedRejectsNull() { RangeValidator validator = new RangeValidator(2); 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 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 NonNegatedRejectsNullForReferenceType() { Validator <string> validator = new RangeValidator <string>("aaaa", RangeBoundaryType.Inclusive, "bbbb", RangeBoundaryType.Inclusive, "test"); ValidationResults results = validator.Validate(null); Assert.IsFalse(results.IsValid); }
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)); }
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 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)); }
// 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); }
/// <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); }
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; } } }
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); }
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); }
public void ShouldReturnFalseForRangeValidatableObject() { Validator rangeValidator = new RangeValidator(falseObject, minValue, maxValue); Assert.IsFalse(rangeValidator.Validate()); }
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 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; }
/// <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()); }