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)); }
/// <summary> /// Loads the property rule from the given xml string and applies /// this to the specified property definition /// </summary> /// <param name="propertyRuleElement">The xml string containing the /// property rule</param> /// <param name="def">The property definition</param> public void LoadRuleIntoProperty(string propertyRuleElement, IPropDef def) { def.AddPropRule( this.LoadRule(def.PropertyTypeName, propertyRuleElement)); }
/// <summary> /// Loads the property rule from the given xml string and applies /// this to the specified property definition /// </summary> /// <param name="propertyRuleElement">The xml string containing the /// property rule</param> /// <param name="def">The property definition</param> public void LoadRuleIntoProperty(string propertyRuleElement, IPropDef def) { def.AddPropRule(this.LoadRule(def.PropertyTypeName, propertyRuleElement)); }