public void Test_GenerateValueLessThan_WhenIntAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(long) }; const int minValue = 3; const int maxValue = 5; const int lessThanValue = int.MaxValue - 77; def.AddPropRule(CreatePropRuleLong(minValue, maxValue)); ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def); //---------------Assert Precondition---------------- Assert.AreSame(typeof(long), def.PropertyType); Assert.IsNotEmpty(def.PropRules.OfType <PropRuleLong>().ToList()); PropRuleLong propRule = def.PropRules.OfType <PropRuleLong>().First(); Assert.AreEqual(minValue, propRule.MinValue); Assert.AreEqual(maxValue, propRule.MaxValue); //---------------Execute Test ---------------------- long value = (long)generator.GenerateValidValueLessThan(lessThanValue); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, minValue); Assert.LessOrEqual(value, lessThanValue); Assert.LessOrEqual(value, maxValue); }
public void Test_GenerateValueLessThan_WhenIntAndNoRule_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(long) }; ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def); const long lessThanValue = long.MinValue + 10; //---------------Assert Precondition---------------- Assert.AreSame(typeof(long), def.PropertyType); Assert.IsEmpty(def.PropRules.OfType <PropRuleLong>().ToList()); //---------------Execute Test ---------------------- var value = (long)generator.GenerateValidValueLessThan(lessThanValue); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, long.MinValue); Assert.LessOrEqual(value, lessThanValue); }
public void Test_GenerateValueLessThan_WhenIntAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(long) }; const int minValue = 3; const int maxValue = 5; const int lessThanValue = int.MaxValue - 77; def.AddPropRule(CreatePropRuleLong(minValue, maxValue)); ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def); //---------------Assert Precondition---------------- Assert.AreSame(typeof(long), def.PropertyType); Assert.IsNotEmpty(def.PropRules.OfType<PropRuleLong>().ToList()); PropRuleLong propRule = def.PropRules.OfType<PropRuleLong>().First(); Assert.AreEqual(minValue, propRule.MinValue); Assert.AreEqual(maxValue, propRule.MaxValue); //---------------Execute Test ---------------------- long value = (long)generator.GenerateValidValueLessThan(lessThanValue); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, minValue); Assert.LessOrEqual(value, lessThanValue); Assert.LessOrEqual(value, maxValue); }
public void Test_GenerateValueLessThan_WhenIntAndNoRule_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(long) }; ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def); const long lessThanValue = long.MinValue + 10; //---------------Assert Precondition---------------- Assert.AreSame(typeof(long), def.PropertyType); Assert.IsEmpty(def.PropRules.OfType<PropRuleLong>().ToList()); //---------------Execute Test ---------------------- var value = (long)generator.GenerateValidValueLessThan(lessThanValue); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, long.MinValue); Assert.LessOrEqual(value, lessThanValue); }