public void Test_GenerateValueGreaterThan_WhenDecimalAndNoRule_ShouldRetValidValue() { IPropDef def = new PropDefFake { PropertyType = typeof(decimal) }; ValidValueGeneratorDecimal generator = new ValidValueGeneratorDecimal(def); Assert.AreSame(typeof(decimal), def.PropertyType); Assert.IsEmpty(def.PropRules.OfType<PropRuleDecimal>().ToList()); decimal value = (decimal) generator.GenerateValidValueGreaterThan(decimal.MaxValue - 5); Assert.IsNotNull(value); Assert.GreaterOrEqual(value, decimal.MaxValue - 5); }
public void Test_GenerateValueGreaterThan_WhenDecimalAndRule_LtNull_ShouldRetValidValueUsingRules() { IPropDef def = new PropDefFake { PropertyType = typeof(decimal) }; def.AddPropRule(CreatePropRuleDecimal(3M, decimal.MaxValue - 7)); ValidValueGeneratorDecimal generator = new ValidValueGeneratorDecimal(def); Assert.AreSame(typeof(decimal), def.PropertyType); Assert.IsNotEmpty(def.PropRules.OfType<PropRuleDecimal>().ToList()); PropRuleDecimal propRule = def.PropRules.OfType<PropRuleDecimal>().First(); Assert.AreEqual(3M, propRule.MinValue); Assert.AreEqual(decimal.MaxValue - 7, propRule.MaxValue); decimal value = (decimal) generator.GenerateValidValueGreaterThan(null); Assert.IsNotNull(value); Assert.GreaterOrEqual(value, 3M); Assert.LessOrEqual(value, decimal.MaxValue - 7); }