private TVItemTVAuth GetFilledRandomTVItemTVAuth(string OmitPropName)
        {
            TVItemTVAuth tvItemTVAuth = new TVItemTVAuth();

            if (OmitPropName != "TVItemUserAuthID")
            {
                tvItemTVAuth.TVItemUserAuthID = GetRandomInt(1, 11);
            }
            if (OmitPropName != "TVText")
            {
                tvItemTVAuth.TVText = GetRandomString("", 6);
            }
            if (OmitPropName != "TVItemID1")
            {
                tvItemTVAuth.TVItemID1 = GetRandomInt(1, 11);
            }
            if (OmitPropName != "TVTypeStr")
            {
                tvItemTVAuth.TVTypeStr = GetRandomString("", 6);
            }
            if (OmitPropName != "TVAuth")
            {
                tvItemTVAuth.TVAuth = (TVAuthEnum)GetRandomEnumType(typeof(TVAuthEnum));
            }
            if (OmitPropName != "TVAuthText")
            {
                tvItemTVAuth.TVAuthText = GetRandomString("", 5);
            }

            return(tvItemTVAuth);
        }
示例#2
0
        /// <summary>
        /// Validate function for all TVItemTVAuthService 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);
            TVItemTVAuth tvItemTVAuth = validationContext.ObjectInstance as TVItemTVAuth;

            tvItemTVAuth.HasErrors = false;

            if (tvItemTVAuth.TVItemUserAuthID < 1)
            {
                tvItemTVAuth.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "TVItemUserAuthID", "1"), new[] { "TVItemUserAuthID" }));
            }

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

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

            if (tvItemTVAuth.TVItemID1 < 1)
            {
                tvItemTVAuth.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "TVItemID1", "1"), new[] { "TVItemID1" }));
            }

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

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

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

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

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                tvItemTVAuth.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
示例#3
0
 public TVItemTVAuthTest()
 {
     tVItemTVAuth = new TVItemTVAuth();
 }