/// <summary> /// Validate function for all TVTypeNamesAndPathService 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); TVTypeNamesAndPath tvTypeNamesAndPath = validationContext.ObjectInstance as TVTypeNamesAndPath; tvTypeNamesAndPath.HasErrors = false; if (string.IsNullOrWhiteSpace(tvTypeNamesAndPath.TVTypeName)) { tvTypeNamesAndPath.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "TVTypeName"), new[] { "TVTypeName" })); } if (!string.IsNullOrWhiteSpace(tvTypeNamesAndPath.TVTypeName) && (tvTypeNamesAndPath.TVTypeName.Length < 1 || tvTypeNamesAndPath.TVTypeName.Length > 255)) { tvTypeNamesAndPath.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "TVTypeName", "1", "255"), new[] { "TVTypeName" })); } if (tvTypeNamesAndPath.Index < 1) { tvTypeNamesAndPath.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "Index", "1"), new[] { "Index" })); } if (string.IsNullOrWhiteSpace(tvTypeNamesAndPath.TVPath)) { tvTypeNamesAndPath.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "TVPath"), new[] { "TVPath" })); } if (!string.IsNullOrWhiteSpace(tvTypeNamesAndPath.TVPath) && (tvTypeNamesAndPath.TVPath.Length < 1 || tvTypeNamesAndPath.TVPath.Length > 255)) { tvTypeNamesAndPath.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "TVPath", "1", "255"), new[] { "TVPath" })); } retStr = ""; // added to stop compiling CSSPError if (retStr != "") // will never be true { tvTypeNamesAndPath.HasErrors = true; yield return(new ValidationResult("AAA", new[] { "AAA" })); } }
private TVTypeNamesAndPath GetFilledRandomTVTypeNamesAndPath(string OmitPropName) { TVTypeNamesAndPath tvTypeNamesAndPath = new TVTypeNamesAndPath(); if (OmitPropName != "TVTypeName") { tvTypeNamesAndPath.TVTypeName = GetRandomString("", 6); } if (OmitPropName != "Index") { tvTypeNamesAndPath.Index = GetRandomInt(1, 11); } if (OmitPropName != "TVPath") { tvTypeNamesAndPath.TVPath = GetRandomString("", 6); } return(tvTypeNamesAndPath); }
public TVTypeNamesAndPathTest() { tVTypeNamesAndPath = new TVTypeNamesAndPath(); }