Habanero.Testability.ValidValueGeneratorString.GenerateValidValue C# (CSharp) Method

GenerateValidValue() public method

Generates a valid value taking into account only the IPropRules. I.e. any InterPropRules will not be taken into account. The IValidValueGeneratorNumeric's methods are used by the BOTestFactory to create valid values taking into account InterPropRules
public GenerateValidValue ( ) : object
return object
        public override object GenerateValidValue()
        {
            return this.GenerateValidValueTyped();
        }

Usage Example

コード例 #1
0
 public void Test_GenerateValue_WhenStringAndMaxLength_ShouldRetToValidValue()
 {
     IPropDef def = new PropDefFake {
         PropertyType = typeof(string)
     };
     def.AddPropRule(CreatePropRuleString(3, 7));
     ValidValueGenerator generator = new ValidValueGeneratorString(def);
     Assert.AreSame(typeof(string), def.PropertyType);
     Assert.IsNotEmpty(def.PropRules.OfType<PropRuleString>().ToList());
     PropRuleString propRule = def.PropRules.OfType<PropRuleString>().First();
     Assert.AreEqual(3, propRule.MinLength);
     Assert.AreEqual(7, propRule.MaxLength);
     object value = generator.GenerateValidValue();
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value.ToString().Length, 3);
     Assert.LessOrEqual(value.ToString().Length, 7);
 }
All Usage Examples Of Habanero.Testability.ValidValueGeneratorString::GenerateValidValue