/// <summary> /// Validates whether the property values set for the BOProp are valid /// as compared to the BOProp rules. This is used by the Business Object /// Validate Method. /// </summary> public void Validate() { // Delayed load validation added for performance based on profiling LGMIS (Brett 12 Jan 2009) if (!_loadedPropHasBeenValidated && !this.IsDirty) { _isValid = _propDef.IsValueValid(this.Value, ref _invalidReason); _loadedPropHasBeenValidated = true; } else if (this.IsDirty) { _isValid = _propDef.IsValueValid(this.Value, ref _invalidReason); } }
public void Test_GetValidValue_WithBO_WhenIsProp_ShouldRetValidValue() { //---------------Set up test pack------------------- var classDef = ClassDef.Get <FakeBO>(); var factory = new BOTestFactory(typeof(FakeBO)); IPropDef def = classDef.PropDefcol.FirstOrDefault(propDef => propDef.PropertyName == "CompulsoryString"); //---------------Assert Precondition---------------- Assert.IsNotNull(def); def.AddPropRule(CreatePropRuleString(3, 7)); //---------------Execute Test ---------------------- var validPropValue = factory.GetValidValue(new FakeBO(), "CompulsoryString"); //---------------Test Result ----------------------- Assert.IsNotNull(validPropValue); string validPropStringValue = validPropValue.ToString(); Assert.GreaterOrEqual(validPropStringValue.Length, 3); Assert.LessOrEqual(validPropStringValue.Length, 7); string errMessage = ""; Assert.IsTrue(def.IsValueValid(validPropStringValue, ref errMessage)); }