コード例 #1
0
        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);
        }
コード例 #2
0
 private static PropRuleString CreatePropRuleString(int minLength, int maxLength)
 {
     return(TestUtilsFactory.CreatePropRuleString(minLength, maxLength));
 }