Exemple #1
0
        public void Test_GenerateValueGreaterThan_WhenDateTimeAndRule_ShouldRetValidValue()
        {
            //---------------Set up test pack-------------------
            IPropDef def = new PropDefFake {
                PropertyType = typeof(DateTime)
            };
            var min = DateTime.Now;
            var max = RandomValueGen.GetAbsoluteMax <DateTime>().AddDays(-5.0);
            var overridingMinValue = max.AddDays(-9.0);

            def.AddPropRule(CreatePropRuleDate(min, max));
            var generator = new ValidValueGeneratorDate(def);

            //---------------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.AddDays(1.0).AddMilliseconds(-1.0), propRule.MaxValue);
            //---------------Execute Test ----------------------
            var value = (DateTime)generator.GenerateValidValueGreaterThan(overridingMinValue);

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.LessOrEqual(value, max);
            Assert.GreaterOrEqual(value, overridingMinValue);
        }
Exemple #2
0
        public void Test_GenerateValueGreaterThan_WhenDateTimeAndNoRule_ShouldRetValidValue()
        {
            //---------------Set up test pack-------------------
            IPropDef def = new PropDefFake {
                PropertyType = typeof(DateTime)
            };
            var generator          = new ValidValueGeneratorDate(def);
            var overridingMinValue = RandomValueGen.GetAbsoluteMax <DateTime>().AddDays(-9.0);

            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(DateTime), def.PropertyType);
            Assert.IsEmpty(def.PropRules.OfType <PropRuleDate>().ToList());
            //---------------Execute Test ----------------------
            var value = (DateTime)generator.GenerateValidValueGreaterThan(overridingMinValue);

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, overridingMinValue);
        }