private SearchTagAndTerms GetFilledRandomSearchTagAndTerms(string OmitPropName)
        {
            SearchTagAndTerms searchTagAndTerms = new SearchTagAndTerms();

            if (OmitPropName != "SearchTag")
            {
                searchTagAndTerms.SearchTag = (SearchTagEnum)GetRandomEnumType(typeof(SearchTagEnum));
            }
            if (OmitPropName != "SearchTagText")
            {
                searchTagAndTerms.SearchTagText = GetRandomString("", 5);
            }
            if (OmitPropName != "SearchTermList")
            {
                searchTagAndTerms.SearchTermList = new List <string>()
                {
                    GetRandomString("", 20), GetRandomString("", 20)
                }
            }
            ;

            return(searchTagAndTerms);
        }

        #endregion Functions private
    }
예제 #2
0
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string            retStr            = "";
            Enums             enums             = new Enums(LanguageRequest);
            SearchTagAndTerms searchTagAndTerms = validationContext.ObjectInstance as SearchTagAndTerms;

            searchTagAndTerms.HasErrors = false;

            retStr = enums.EnumTypeOK(typeof(SearchTagEnum), (int?)searchTagAndTerms.SearchTag);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                searchTagAndTerms.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "SearchTag"), new[] { "SearchTag" }));
            }

            if (!string.IsNullOrWhiteSpace(searchTagAndTerms.SearchTagText) && searchTagAndTerms.SearchTagText.Length > 100)
            {
                searchTagAndTerms.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "SearchTagText", "100"), new[] { "SearchTagText" }));
            }

            //CSSPError: Type not implemented [SearchTermList] of type [List`1]

            //SearchTermList has no StringLength Attribute

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                searchTagAndTerms.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
예제 #3
0
 public SearchTagAndTermsTest()
 {
     searchTagAndTerms = new SearchTagAndTerms();
 }