private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType) { string retStr = ""; Enums enums = new Enums(LanguageRequest); FilePurposeAndText filePurposeAndText = validationContext.ObjectInstance as FilePurposeAndText; filePurposeAndText.HasErrors = false; retStr = enums.EnumTypeOK(typeof(FilePurposeEnum), (int?)filePurposeAndText.FilePurpose); if (!string.IsNullOrWhiteSpace(retStr)) { filePurposeAndText.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "FilePurpose"), new[] { "FilePurpose" })); } if (!string.IsNullOrWhiteSpace(filePurposeAndText.FilePurposeText) && filePurposeAndText.FilePurposeText.Length > 100) { filePurposeAndText.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "FilePurposeText", "100"), new[] { "FilePurposeText" })); } retStr = ""; // added to stop compiling CSSPError if (retStr != "") // will never be true { filePurposeAndText.HasErrors = true; yield return(new ValidationResult("AAA", new[] { "AAA" })); } }
private FilePurposeAndText GetFilledRandomFilePurposeAndText(string OmitPropName) { FilePurposeAndText filePurposeAndText = new FilePurposeAndText(); if (OmitPropName != "FilePurpose") { filePurposeAndText.FilePurpose = (FilePurposeEnum)GetRandomEnumType(typeof(FilePurposeEnum)); } if (OmitPropName != "FilePurposeText") { filePurposeAndText.FilePurposeText = GetRandomString("", 5); } return(filePurposeAndText); }
private List <FilePurposeAndText> FillFilePurposeAndTextList() { List <FilePurposeAndText> filePurposeAndTextList = new List <FilePurposeAndText>(); for (int i = 1, count = Enum.GetNames(typeof(FilePurposeEnum)).Length; i < count; i++) { FilePurposeAndText filePurposeAndText = new FilePurposeAndText() { FilePurpose = (FilePurposeEnum)i, FilePurposeText = _BaseEnumService.GetEnumText_FilePurposeEnum((FilePurposeEnum)i) }; filePurposeAndTextList.Add(filePurposeAndText); } return(filePurposeAndTextList); }
public FilePurposeAndTextTest() { filePurposeAndText = new FilePurposeAndText(); }