private int GenerateValidValue(int?overridingMinValue, int?overridingMaxValue) { var propRule = base.GetPropRule <PropRuleInteger>(); var intMinValue = GetMinValue(propRule, overridingMinValue); var intMaxValue = GetMaxValue(propRule, overridingMaxValue); return(RandomValueGen.GetRandomInt(intMinValue, intMaxValue)); }
/// <summary> /// Generates a valid value taking into account only the <see cref="IPropRule"/>s. I.e. any <see cref="InterPropRule"/>s /// will not be taken into account. The <see cref="IValidValueGeneratorNumeric"/>'s methods are used /// by the BOTestFactory to create valid values taking into account InterPropRules /// </summary> /// <returns></returns> public override object GenerateValidValue() { CreateSampleValues(); var randomPos = RandomValueGen.GetRandomInt(0, SampleValues.Count - 1); object sampleValue = SampleValues[randomPos]; if (this.SingleValueDef.PropertyType != typeof(string)) { var typeConverter = TypeDescriptor.GetConverter(SingleValueDef.PropertyType); if (typeConverter != null) { if (typeConverter.CanConvertTo(SingleValueDef.PropertyType)) { sampleValue = typeConverter.ConvertTo(sampleValue, SingleValueDef.PropertyType); } } } return(sampleValue); }