public void Test_GetValidPropValue_WhenStringAndMaxLengthWhenPropDef_ShouldRetValidValue()
        {
            //---------------Set up test pack-------------------
            IPropDef def = new PropDefFake {
                PropertyType = typeof(string)
            };

            def.AddPropRule(CreatePropRuleString(3, 7));
            var factory = new BOTestFactory(typeof(FakeBO));

            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(string), def.PropertyType);
            Assert.IsNotEmpty(def.PropRules.OfType <PropRuleString>().ToList());
            var propRule = def.PropRules.OfType <PropRuleString>().First();

            Assert.AreEqual(3, propRule.MinLength);
            Assert.AreEqual(7, propRule.MaxLength);
            //---------------Execute Test ----------------------
            var validPropValue = factory.GetValidPropValue(def);

            //---------------Test Result -----------------------
            Assert.IsNotNull(validPropValue);
            Assert.GreaterOrEqual(validPropValue.ToString().Length, 3);
            Assert.LessOrEqual(validPropValue.ToString().Length, 7);
            string errMessage = "";

            Assert.IsTrue(def.IsValueValid(validPropValue, ref errMessage));
        }
        public void Test_GetValidPropValue_WhenDateTimeAndMaxValue_WhenPropName_ShouldRetValidValue()
        {
            //---------------Set up test pack-------------------
            IPropDef def = new PropDefFake {
                PropertyType = typeof(DateTime)
            };
            DateTime min = RandomValueGen.GetAbsoluteMin <DateTime>().AddDays(5555.0);
            DateTime max = RandomValueGen.GetAbsoluteMin <DateTime>().AddDays(5565.0);

            def.AddPropRule(TestUtilsFactory.CreatePropRuleDateTime(min, max));
            var factory = new BOTestFactory(typeof(FakeBO));

            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(DateTime), def.PropertyType);
            Assert.IsNotEmpty(def.PropRules.OfType <PropRuleDate>().ToList());
            var propRule = def.PropRules.OfType <PropRuleDate>().First();

            Assert.AreEqual(min, propRule.MinValue);
            Assert.AreEqual(max, propRule.MaxValue.Date);
            //---------------Execute Test ----------------------
            var validPropValue = factory.GetValidPropValue(def);

            //---------------Test Result -----------------------
            Assert.GreaterOrEqual((DateTime)validPropValue, min);
            Assert.LessOrEqual((DateTime)validPropValue, max);
            string errMessage = "";

            Assert.IsTrue(def.IsValueValid(validPropValue, ref errMessage), errMessage);
        }
 public void Test_GetValidPropValue_WhenStringAndMaxLengthWhenPropDef_ShouldRetValidValue()
 {
     //---------------Set up test pack-------------------
     IPropDef def = new PropDefFake {
         PropertyType = typeof(string)
     };
     def.AddPropRule(CreatePropRuleString(3, 7));
     var factory = new BOTestFactory(typeof(FakeBO));
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(string), def.PropertyType);
     Assert.IsNotEmpty(def.PropRules.OfType<PropRuleString>().ToList());
     var propRule = def.PropRules.OfType<PropRuleString>().First();
     Assert.AreEqual(3, propRule.MinLength);
     Assert.AreEqual(7, propRule.MaxLength);
     //---------------Execute Test ----------------------
     var validPropValue = factory.GetValidPropValue(def);
     //---------------Test Result -----------------------
     Assert.IsNotNull(validPropValue);
     Assert.GreaterOrEqual(validPropValue.ToString().Length, 3);
     Assert.LessOrEqual(validPropValue.ToString().Length, 7);
     string errMessage = "";
     Assert.IsTrue(def.IsValueValid(validPropValue, ref errMessage));
 }
 public void Test_GetValidPropValue_WhenDateTimeAndMaxValue_WhenPropName_ShouldRetValidValue()
 {
     //---------------Set up test pack-------------------
     IPropDef def = new PropDefFake {
         PropertyType = typeof(DateTime)
     };
     DateTime min = RandomValueGen.GetAbsoluteMin<DateTime>().AddDays(5555.0);
     DateTime max = RandomValueGen.GetAbsoluteMin<DateTime>().AddDays(5565.0);
     def.AddPropRule(TestUtilsFactory.CreatePropRuleDateTime(min, max));
     var factory = new BOTestFactory(typeof(FakeBO));
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(DateTime), def.PropertyType);
     Assert.IsNotEmpty(def.PropRules.OfType<PropRuleDate>().ToList());
     var propRule = def.PropRules.OfType<PropRuleDate>().First();
     Assert.AreEqual(min, propRule.MinValue);
     Assert.AreEqual(max, propRule.MaxValue.Date);
     //---------------Execute Test ----------------------
     var validPropValue = factory.GetValidPropValue(def);
     //---------------Test Result -----------------------
     Assert.GreaterOrEqual((DateTime) validPropValue, min);
     Assert.LessOrEqual((DateTime) validPropValue, max);
     string errMessage = "";
     Assert.IsTrue(def.IsValueValid(validPropValue, ref errMessage), errMessage);
 }