Esempio n. 1
0
        private TVFullText GetFilledRandomTVFullText(string OmitPropName)
        {
            TVFullText tvFullText = new TVFullText();

            if (OmitPropName != "TVPath")
            {
                tvFullText.TVPath = GetRandomString("", 6);
            }
            if (OmitPropName != "FullText")
            {
                tvFullText.FullText = GetRandomString("", 6);
            }

            return(tvFullText);
        }
        /// <summary>
        /// Validate function for all TVFullTextService commands
        /// </summary>
        /// <param name="validationContext">System.ComponentModel.DataAnnotations.ValidationContext (Describes the context in which a validation check is performed.)</param>
        /// <param name="actionDBType">[ActionDBTypeEnum] (CSSPEnums.ActionDBTypeEnum.html) action type to validate</param>
        /// <returns>IEnumerable of ValidationResult (Where ValidationResult is a container for the results of a validation request.)</returns>
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string     retStr     = "";
            Enums      enums      = new Enums(LanguageRequest);
            TVFullText tvFullText = validationContext.ObjectInstance as TVFullText;

            tvFullText.HasErrors = false;

            if (string.IsNullOrWhiteSpace(tvFullText.TVPath))
            {
                tvFullText.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "TVPath"), new[] { "TVPath" }));
            }

            if (!string.IsNullOrWhiteSpace(tvFullText.TVPath) && (tvFullText.TVPath.Length < 1 || tvFullText.TVPath.Length > 255))
            {
                tvFullText.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "TVPath", "1", "255"), new[] { "TVPath" }));
            }

            if (string.IsNullOrWhiteSpace(tvFullText.FullText))
            {
                tvFullText.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "FullText"), new[] { "FullText" }));
            }

            if (!string.IsNullOrWhiteSpace(tvFullText.FullText) && (tvFullText.FullText.Length < 1 || tvFullText.FullText.Length > 255))
            {
                tvFullText.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "FullText", "1", "255"), new[] { "FullText" }));
            }

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                tvFullText.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
 public TVFullTextTest()
 {
     tVFullText = new TVFullText();
 }