public GenerateValidValueGreaterThan ( object minValue ) : object | ||
minValue | object | |
return | object |
public void Test_GenerateValueGreaterThan_WhenIntAndRule_LtNull_ShouldRetValidValueUsingRules() { IPropDef def = new PropDefFake { PropertyType = typeof(int) }; const int minValue = 3; const int maxValue = 20; def.AddPropRule(CreatePropRuleInt(minValue, maxValue)); ValidValueGeneratorInt generator = new ValidValueGeneratorInt(def); //---------------Assert Precondition---------------- Assert.AreSame(typeof(int), def.PropertyType); Assert.IsNotEmpty(def.PropRules.OfType<PropRuleInteger>().ToList()); PropRuleInteger propRule = def.PropRules.OfType<PropRuleInteger>().First(); Assert.AreEqual(minValue, propRule.MinValue); Assert.AreEqual(maxValue, propRule.MaxValue); //---------------Execute Test ---------------------- int value = (int)generator.GenerateValidValueGreaterThan(null); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, minValue); Assert.LessOrEqual(value,maxValue); }
public void Test_GenerateValueGreaterThan_WhenIntAndNoRule_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(int) }; ValidValueGeneratorInt generator = new ValidValueGeneratorInt(def); //---------------Assert Precondition---------------- Assert.AreSame(typeof(int), def.PropertyType); Assert.IsEmpty(def.PropRules.OfType<PropRuleInteger>().ToList()); //---------------Execute Test ---------------------- int value = (int)generator.GenerateValidValueGreaterThan(int.MaxValue - 5); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, int.MaxValue - 5); }