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; }
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)); }