/// <summary> /// Adds an error validator to the EditControlContainer and to the Page.Validators collection. /// Override since we want to add the validator to the correct control collection. /// </summary> /// <param name="errorMessage">The error message.</param> /// <remarks>This method is used to indicate that invalid data has been entered by the user.</remarks> public override void AddErrorValidator(string errorMessage) { StaticValidator validator = new StaticValidator(errorMessage); validator.Text = "*"; validator.ValidationGroup = ValidationGroup; EditControlContainer.Controls.Add(validator); }
public void Handle_ThrowsBusniessRulexception() { IRequestHandler <Request, string> inner = Substitute.For <IRequestHandler <Request, string> >(); var logger = Substitute.For <ILogger>(); var validator = new StaticValidator(false); var handler = new ValidationHandler <Request, string>(inner, validator, logger); var e = Assert.Throws <BusinessRuleException>(() => handler.Handle(new Request())); Assert.AreEqual(e.Violations.First().PropertyName, "foo"); Assert.AreEqual(e.Violations.First().Violation, "bar"); inner.DidNotReceive().Handle(Arg.Any <Request>()); }
private bool Validate() { if (!StaticValidator.VerifyGetNumberSetting(CheckBoxSpecialNumber.Checked, textBoxGetCount.Text)) { String showString = "取得號碼的個數設定值必須為數字,且數值大於0。"; if (CheckBoxSpecialNumber.Checked == true) { showString += "設定有特別號時,取得號碼的個數設定值必須大於等於1"; } MessageBox.Show(showString); return(false); } if (radioButtonCount.Checked) { if (!StaticValidator.VerifyNumber(textBoxNumberCount.Text)) { MessageBox.Show("來源號碼的個數必須為數字,且數值大於0"); return(false); } if (!StaticValidator.VerifyNumberRelationship(textBoxNumberCount.Text, textBoxGetCount.Text)) { MessageBox.Show("取得的個數必須小於等於來源號碼的個數"); return(false); } } else { if (!StaticValidator.VerifyNumberRange(textBoxStartNumber.Text, textBoxEndNumber.Text)) { MessageBox.Show("來源號碼的範圍數值必須為數字,且開始號碼必須小於等於結束號碼"); return(false); } if (!StaticValidator.VerifyNumberRelationship(textBoxStartNumber.Text, textBoxEndNumber.Text, textBoxGetCount.Text)) { MessageBox.Show("取得的個數必須小於等於來源號碼的個數"); return(false); } } return(true); }