public void Test_GenerateValueGreaterThan_WhenIntAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(int) }; const int minValue = 3; const int maxValue = 8; def.AddPropRule(CreatePropRuleInt(minValue, maxValue)); const int greaterThanValue = int.MinValue + 10; ValidValueGeneratorIncrementalInt generator = new ValidValueGeneratorIncrementalInt(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(greaterThanValue); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.LessOrEqual(value, maxValue); Assert.GreaterOrEqual(value, minValue); Assert.GreaterOrEqual(value, greaterThanValue); }
public void Test_GenerateValueGreaterThan_WhenIntAndNoRule_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(int) }; ValidValueGeneratorIncrementalInt generator = new ValidValueGeneratorIncrementalInt(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); }