public void Test_GenerateValueGreaterThan_WhenIntAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(long) }; const int minValue = 3; const int maxValue = 8; def.AddPropRule(CreatePropRuleLong(minValue, maxValue)); const int greaterThanValue = int.MinValue + 10; 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 ---------------------- var value = (long)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(long) }; ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def); //---------------Assert Precondition---------------- Assert.AreSame(typeof(long), def.PropertyType); Assert.IsEmpty(def.PropRules.OfType <PropRuleLong>().ToList()); //---------------Execute Test ---------------------- var value = (long)generator.GenerateValidValueGreaterThan(int.MaxValue - 5); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, int.MaxValue - 5); }
public void Test_GenerateValueGreaterThan_WhenIntAndRule_LtNull_ShouldRetValidValueUsingRules() { IPropDef def = new PropDefFake { PropertyType = typeof(long) }; const int minValue = 3; const int maxValue = 20; 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 ---------------------- var value = (long)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(long) }; ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def); //---------------Assert Precondition---------------- Assert.AreSame(typeof(long), def.PropertyType); Assert.IsEmpty(def.PropRules.OfType<PropRuleLong>().ToList()); //---------------Execute Test ---------------------- var value = (long)generator.GenerateValidValueGreaterThan(int.MaxValue - 5); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.GreaterOrEqual(value, int.MaxValue - 5); }