private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType) { string retStr = ""; Enums enums = new Enums(LanguageRequest); BoxModelCalNumb boxModelCalNumb = validationContext.ObjectInstance as BoxModelCalNumb; boxModelCalNumb.HasErrors = false; retStr = enums.EnumTypeOK(typeof(BoxModelResultTypeEnum), (int?)boxModelCalNumb.BoxModelResultType); if (!string.IsNullOrWhiteSpace(retStr)) { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "BoxModelResultType"), new[] { "BoxModelResultType" })); } if (boxModelCalNumb.CalLength_m < 0) { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "CalLength_m", "0"), new[] { "CalLength_m" })); } if (boxModelCalNumb.CalRadius_m < 0) { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "CalRadius_m", "0"), new[] { "CalRadius_m" })); } if (boxModelCalNumb.CalSurface_m2 < 0) { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "CalSurface_m2", "0"), new[] { "CalSurface_m2" })); } if (boxModelCalNumb.CalVolume_m3 < 0) { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "CalVolume_m3", "0"), new[] { "CalVolume_m3" })); } if (boxModelCalNumb.CalWidth_m < 0) { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "CalWidth_m", "0"), new[] { "CalWidth_m" })); } if (!string.IsNullOrWhiteSpace(boxModelCalNumb.BoxModelResultTypeText) && boxModelCalNumb.BoxModelResultTypeText.Length > 100) { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "BoxModelResultTypeText", "100"), new[] { "BoxModelResultTypeText" })); } retStr = ""; // added to stop compiling CSSPError if (retStr != "") // will never be true { boxModelCalNumb.HasErrors = true; yield return(new ValidationResult("AAA", new[] { "AAA" })); } }
private BoxModelCalNumb GetFilledRandomBoxModelCalNumb(string OmitPropName) { BoxModelCalNumb boxModelCalNumb = new BoxModelCalNumb(); if (OmitPropName != "BoxModelResultType") { boxModelCalNumb.BoxModelResultType = (BoxModelResultTypeEnum)GetRandomEnumType(typeof(BoxModelResultTypeEnum)); } if (OmitPropName != "CalLength_m") { boxModelCalNumb.CalLength_m = GetRandomDouble(0.0D, 10.0D); } if (OmitPropName != "CalRadius_m") { boxModelCalNumb.CalRadius_m = GetRandomDouble(0.0D, 10.0D); } if (OmitPropName != "CalSurface_m2") { boxModelCalNumb.CalSurface_m2 = GetRandomDouble(0.0D, 10.0D); } if (OmitPropName != "CalVolume_m3") { boxModelCalNumb.CalVolume_m3 = GetRandomDouble(0.0D, 10.0D); } if (OmitPropName != "CalWidth_m") { boxModelCalNumb.CalWidth_m = GetRandomDouble(0.0D, 10.0D); } if (OmitPropName != "FixLength") { boxModelCalNumb.FixLength = true; } if (OmitPropName != "FixWidth") { boxModelCalNumb.FixWidth = true; } if (OmitPropName != "BoxModelResultTypeText") { boxModelCalNumb.BoxModelResultTypeText = GetRandomString("", 5); } return(boxModelCalNumb); }
public BoxModelCalNumbTest() { boxModelCalNumb = new BoxModelCalNumb(); }