public void Test_GenerateValue_WhenDecimal_ShouldSet()
        {
            Type     propertyType = typeof(decimal);
            IPropDef def          = new PropDefFake {
                PropertyType = propertyType
            };
            ValidValueGenerator valueGenerator = new ValidValueGeneratorDecimal(def);
            object value = valueGenerator.GenerateValidValue();

            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(decimal), value);
            Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
        }
        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);
        }
        public void Test_GenerateValue_WhenDecimapAndRule_ShouldRetValidValue()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(decimal)
            };

            def.AddPropRule(CreatePropRuleDecimal(3.01M, 7.0004M));
            ValidValueGenerator 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(3.01M, propRule.MinValue);
            Assert.AreEqual(7.0004M, propRule.MaxValue);
            decimal value = (decimal)generator.GenerateValidValue();

            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, 3.01M);
            Assert.LessOrEqual(value, 7.0004M);
        }