protected void SkuCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
    {
        string sku = args.Value;
        string errorMessage;
        bool   isValid = _presenter.IsSkuValid(sku, out errorMessage);

        if (!isValid)
        {
            CustomValidator validator = source as CustomValidator;
            validator.ErrorMessage = errorMessage;
        }
        args.IsValid = isValid;
    }
예제 #2
0
        public void SkuIsNotValidIfEmptyOrNull()
        {
            string sku          = string.Empty;
            string errorMessage = string.Empty;

            Assert.IsFalse(presenter.IsSkuValid(sku, out errorMessage));
            Assert.IsFalse(string.IsNullOrEmpty(errorMessage));

            sku = null;
            Assert.IsFalse(presenter.IsSkuValid(sku, out errorMessage));
            Assert.IsFalse(string.IsNullOrEmpty(errorMessage));
        }