상속: PropDef
예제 #1
0
        public void Test_GenerateValueLessThan_WhenIntAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };
            const int minValue      = 3;
            const int maxValue      = 5;
            const int lessThanValue = int.MaxValue - 77;

            def.AddPropRule(CreatePropRuleInt(minValue, maxValue));
            ValidValueGeneratorIncrementalInt generator = new ValidValueGeneratorIncrementalInt(def);

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

            Assert.AreEqual(minValue, propRule.MinValue);
            Assert.AreEqual(maxValue, propRule.MaxValue);
            //---------------Execute Test ----------------------
            int value = (int)generator.GenerateValidValueLessThan(lessThanValue);

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, minValue);
            Assert.LessOrEqual(value, lessThanValue);
            Assert.LessOrEqual(value, maxValue);
        }
        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);
        }
예제 #3
0
        public void Test_GenerateValue_WhenIntAndRule_AndNextValGTMaxVal_ShouldRestartAtMin()
        {
            //---------------Set up test pack-------------------

            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };
            const int minValue = 3;
            const int maxValue = 4;

            def.AddPropRule(CreatePropRuleInt(minValue, maxValue));
            ValidValueGenerator generator = new ValidValueGeneratorIncrementalInt(def);

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

            Assert.AreEqual(minValue, propRule.MinValue);
            Assert.AreEqual(maxValue, propRule.MaxValue);
            //---------------Execute Test ----------------------
            var value1 = (int)generator.GenerateValidValue();
            var value2 = (int)generator.GenerateValidValue();
            int value3 = (int)generator.GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.AreEqual(minValue, value1);
            Assert.AreEqual(maxValue, value2);
            Assert.AreEqual(minValue, value3);
        }
        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));
        }
예제 #5
0
        public void Test_GenerateValidValue_WhenPropTypeString_ShouldRetItemInList()
        {
            //---------------Set up test pack-------------------
            Type     propertyType = typeof(string);
            IPropDef def          = new PropDefFake
            {
                PropertyType = propertyType
            };
            var dictionary = new Dictionary <string, string>
            {
                { "fda", "fdafasd" },
                { "fdadffasdf", "gjhj" }
            };

            def.LookupList = new SimpleLookupList(dictionary);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(def.LookupList);
            Assert.AreEqual(2, def.LookupList.GetLookupList().Count);
            //---------------Execute Test ----------------------
            object value = new ValidValueGeneratorLookupList(def).GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(string), value);
            StringAssert.StartsWith("fda", value.ToString());
        }
예제 #6
0
        public void Test_GenerateValue_WhenDateTimeAndRule_ShouldRetValidValue()
        {
            //---------------Set up test pack-------------------
            IPropDef def = new PropDefFake {
                PropertyType = typeof(DateTime)
            };
            var min = RandomValueGen.GetAbsoluteMin <DateTime>().AddDays(5555.0);
            var max = RandomValueGen.GetAbsoluteMin <DateTime>().AddDays(5565.0);

            def.AddPropRule(CreatePropRuleDate(min, max));
            ValidValueGenerator 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, propRule.MaxValue.Date);
            //---------------Execute Test ----------------------
            var value = (DateTime)generator.GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, min);
            Assert.LessOrEqual(value, max);
        }
예제 #7
0
        public void Test_GenerateValueGreaterThan_WhenShortAndRule_LtNull_ShouldRetValidValueUsingRules()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(short)
            };
            const short minValue = 3;
            const short maxValue = 20;

            def.AddPropRule(CreatePropRuleShort(minValue, maxValue));
            var generator = CreateValidValueGenerator(def);

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

            Assert.AreEqual(minValue, propRule.MinValue);
            Assert.AreEqual(maxValue, propRule.MaxValue);
            //---------------Execute Test ----------------------
            var value = (short)generator.GenerateValidValueGreaterThan(null);

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, minValue);
            Assert.LessOrEqual(value, maxValue);
        }
예제 #8
0
        public void Test_GenerateValueLessThan_WhenIntAndRule_LtNull_ShouldRetValidValueUsingRules()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(long)
            };
            const int maxValue = int.MaxValue - 77;
            const int minValue = 3;

            def.AddPropRule(CreatePropRuleLong(minValue, maxValue));
            ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def);

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

            Assert.AreEqual(minValue, propRule.MinValue);
            Assert.AreEqual(maxValue, propRule.MaxValue);
            //---------------Execute Test ----------------------
            long value = (long)generator.GenerateValidValueLessThan(null);

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, minValue);
            Assert.LessOrEqual(value, maxValue);
        }
예제 #9
0
        public void Test_GenerateValueLessThan_WhenDateTimeAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue()
        {
            //---------------Set up test pack-------------------
            IPropDef def = new PropDefFake {
                PropertyType = typeof(DateTime)
            };
            var min = DateTime.Now;
            var max = DateTime.Today.AddDays(5.0);
            var overridingMaxValue = RandomValueGen.GetAbsoluteMax <DateTime>().AddDays(-5.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.GenerateValidValueLessThan(overridingMaxValue);

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, min);
            Assert.LessOrEqual(value, max);
            Assert.LessOrEqual(value, overridingMaxValue);
        }
예제 #10
0
        public void Test_GenerateValidValue_WhenPropTypeGuid_ShouldReturnItemInListAsGuid()
        {
            //---------------Set up test pack-------------------
            Type     guidPropType = typeof(Guid);
            IPropDef def          = new PropDefFake
            {
                PropertyType = guidPropType
            };

            RandomValueGen.GetRandomGuid().ToString();
            var dictionary = new Dictionary <string, string>
            {
                { "fdafasd", RandomValueGen.GetRandomGuid().ToString() }
            };

            def.LookupList = new SimpleLookupList(dictionary);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(def.LookupList);
            Assert.AreEqual(1, def.LookupList.GetLookupList().Count);
            Assert.AreSame(guidPropType, def.PropertyType);
            //---------------Execute Test ----------------------
            object value = new ValidValueGeneratorLookupList(def).GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.IsInstanceOf(guidPropType, value, value + " should be of type guid");
        }
예제 #11
0
        public void Test_GenerateValue_WhenIntAndRule_ShouldRetValidValue()
        {
            //---------------Set up test pack-------------------

            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };

            def.AddPropRule(CreatePropRuleInt(3, 7));
            ValidValueGenerator generator = new ValidValueGeneratorInt(def);

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

            Assert.AreEqual(3, propRule.MinValue);
            Assert.AreEqual(7, propRule.MaxValue);
            int value = (int)generator.GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, 3);
            Assert.LessOrEqual(value, 7);
        }
 public void Test_GenerateValue_WhenBool_ShouldGetBool()
 {
     Type propertyType = typeof(bool);
     IPropDef def = new PropDefFake {
         PropertyType = propertyType
     };
     object value = new ValidValueGeneratorBool(def).GenerateValidValue();
     Assert.IsNotNull(value);
     Assert.IsInstanceOf(typeof(bool), value);
 }
 private static ValidValueGeneratorRegEx CreateValueGenerator(string regExPhrase, ISingleValueDef singleValueDef = null)
 {
     if (singleValueDef == null)
     {
         singleValueDef = new PropDefFake
         {
             PropertyType = typeof(string)
         };
     }
     return(new ValidValueGeneratorRegEx(singleValueDef, regExPhrase));
 }
        public void Test_GenerateValue_WhenEnum_ShouldSet()
        {
            Type     propertyType = typeof(FakeEnum);
            IPropDef def          = new PropDefFake {
                PropertyType = propertyType
            };
            object value = new ValidValueGeneratorEnum(def).GenerateValidValue();

            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(FakeEnum), value);
        }
        public void Test_GenerateValue_WhenBool_ShouldGetBool()
        {
            Type     propertyType = typeof(bool);
            IPropDef def          = new PropDefFake {
                PropertyType = propertyType
            };
            object value = new ValidValueGeneratorBool(def).GenerateValidValue();

            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(bool), value);
        }
 private static ValidValueGeneratorTextFile CreateValueGenerator(string fileName, IPropDef propDef = null)
 {
     if (propDef == null)
     {
         propDef = new PropDefFake
         {
             PropertyType = typeof(string)
         };
     }
     return(new ValidValueGeneratorTextFile(propDef, fileName));
 }
        public void Test_GenerateValue_WhenGuid_ShouldRetGuid()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(Guid)
            };
            ValidValueGenerator valueGenerator = new ValidValueGeneratorGuid(def);
            object value = valueGenerator.GenerateValidValue();

            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(Guid), value);
            Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
        }
 public void Test_GenerateValueGreaterThan_WhenDoubleAndNoRule_ShouldRetValidValue()
 {
     IPropDef def = new PropDefFake {
         PropertyType = typeof(double)
     };
     var generator = new ValidValueGeneratorDouble(def);
     Assert.AreSame(typeof(double), def.PropertyType);
     Assert.IsEmpty(def.PropRules.OfType<PropRuleDouble>().ToList<PropRuleDouble>());
     var value = (double) generator.GenerateValidValueGreaterThan(1.7976931348623157E+308);
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, double.MaxValue);
 }
 public void Test_GenerateValue_WhenDateTime_ShouldSet()
 {
     Type propertyType = typeof(DateTime);
     IPropDef def = new PropDefFake {
         PropertyType = propertyType
     };
     ValidValueGenerator valueGenerator = new ValidValueGeneratorDate(def);
     object value = valueGenerator.GenerateValidValue();
     Assert.IsNotNull(value);
     Assert.IsInstanceOf(typeof(DateTime), 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_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_WhenDoubleAndNoRule_ShouldRetValidValue()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(double)
            };
            var generator = new ValidValueGeneratorDouble(def);

            Assert.AreSame(typeof(double), def.PropertyType);
            Assert.IsEmpty(def.PropRules.OfType <PropRuleDouble>().ToList <PropRuleDouble>());
            var value = (double)generator.GenerateValidValueGreaterThan(1.7976931348623157E+308);

            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, double.MaxValue);
        }
        public void Test_GenerateValue_WhenString_ShouldRetToString()
        {
            IPropDef def = new PropDefFake {
                Compulsory   = true,
                PropertyType = typeof(string)
            };
            ValidValueGeneratorString valueGenerator = new ValidValueGeneratorString(def);
            object value = valueGenerator.GenerateValidValue();

            Assert.IsNotNull(value);
            Assert.IsNotNullOrEmpty(value.ToString());
            Assert.IsInstanceOf(typeof(string), value);
            Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
        }
 public void Test_Register_WhenStdValidValueGenerator_WithValueGen_ShouldReturnWhenResolved()
 {
     //---------------Set up test pack-------------------
     var registry = new ValidValueGeneratorRegistry();
     registry.Register<string>(typeof(ValidValueGeneratorString));
     PropDefFake propDef = new PropDefFake();
     propDef.PropertyType = typeof(string);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(string), propDef.PropertyType);
     //---------------Execute Test ----------------------
     ValidValueGenerator boTestFactory = registry.Resolve(propDef);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ValidValueGeneratorString>(boTestFactory);
 }
 public void Test_GenerateValue_WhenShort_ShouldRetShort()
 {
     IPropDef def = new PropDefFake {
                                        PropertyType = typeof(short)
                                    };
     var valueGenerator = CreateValidValueGenerator(def);
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var value = valueGenerator.GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.IsInstanceOf(typeof(short), value);
     Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
 }
 public void Test_GenerateValue_WhenInt_ShouldRetInt()
 {
     IPropDef def = new PropDefFake {
         PropertyType = typeof(int)
     };
     ValidValueGenerator valueGenerator = new ValidValueGeneratorIncrementalInt(def);
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     object value = valueGenerator.GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.IsInstanceOf(typeof(int), 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_WhenIntAndNoRule_ShouldRetValidValue()
 {
     IPropDef def = new PropDefFake {
                                        PropertyType = typeof(long)
                                    };
     ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(long), def.PropertyType);
     Assert.IsEmpty(def.PropRules.OfType<PropRuleLong>().ToList());
     //---------------Execute Test ----------------------
     var value = (long)generator.GenerateValidValueGreaterThan(int.MaxValue - 5);
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, int.MaxValue - 5);
 }
예제 #29
0
        public void Test_GenerateValue_WhenShort_ShouldRetShort()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(short)
            };
            var valueGenerator = CreateValidValueGenerator(def);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var value = valueGenerator.GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(short), value);
            Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
        }
 public void Test_GenerateValueGreaterThan_WhenShortAndNoRule_ShouldRetValidValue()
 {
     IPropDef def = new PropDefFake {
                                        PropertyType = typeof(short)
                                    };
     var generator = CreateValidValueGenerator(def);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(short), def.PropertyType);
     Assert.IsEmpty(def.PropRules.OfType<PropRuleShort>().ToList());
     //---------------Execute Test ----------------------
     var value = (short)generator.GenerateValidValueGreaterThan(Convert.ToInt16(short.MaxValue - 5));
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, short.MaxValue - 5);
 }
예제 #31
0
        public void Test_GetValidValueGenerator_WhenEnum_ShouldRetEnumGenerator()
        {
            //---------------Set up test pack-------------------
            IPropDef def = new PropDefFake
            {
                PropertyType = typeof(FakeEnum)
            };
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var generator = new BOTestFactory <FakeBOWithRules>().GetValidValueGenerator(def);

            //---------------Test Result -----------------------
            Assert.IsNotNull(generator);
            Assert.IsInstanceOf <ValidValueGeneratorEnum>(generator);
        }
예제 #32
0
        public void Test_Resolve_WithShort_ShouldReturnValidValueGeneratorShort()
        {
            //---------------Set up test pack-------------------
            var registry = new ValidValueGeneratorRegistry();
            var propDef  = new PropDefFake {
                PropertyType = typeof(short)
            };

            //---------------Execute Test ----------------------
            var validValueGenerator = registry.Resolve(propDef);

            //---------------Test Result -----------------------
            Assert.IsNotNull(validValueGenerator);
            Assert.IsInstanceOf <ValidValueGeneratorShort>(validValueGenerator);
        }
예제 #33
0
        public void Test_GenerateValue_WhenInt_ShouldRetInt()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };
            ValidValueGenerator valueGenerator = new ValidValueGeneratorIncrementalInt(def);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            object value = valueGenerator.GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(int), value);
            Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
        }
 public void Test_GenerateValue_WhenDateTime_ShouldSet()
 {
     //---------------Set up test pack-------------------
     var propertyType = typeof(DateTime);
     IPropDef def = new PropDefFake {
         PropertyType = propertyType
     };
     ValidValueGenerator valueGenerator = new ValidValueGeneratorDate(def);
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var value = valueGenerator.GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.IsInstanceOf(typeof(DateTime), value);
     Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
 }
예제 #35
0
        public void Test_GenerateValueGreaterThan_WhenShortAndNoRule_ShouldRetValidValue()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(short)
            };
            var generator = CreateValidValueGenerator(def);

            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(short), def.PropertyType);
            Assert.IsEmpty(def.PropRules.OfType <PropRuleShort>().ToList());
            //---------------Execute Test ----------------------
            var value = (short)generator.GenerateValidValueGreaterThan(Convert.ToInt16(short.MaxValue - 5));

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, short.MaxValue - 5);
        }
 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);
 }
예제 #37
0
        public void Test_GenerateValue_WhenDateTime_ShouldSet()
        {
            //---------------Set up test pack-------------------
            var      propertyType = typeof(DateTime);
            IPropDef def          = new PropDefFake {
                PropertyType = propertyType
            };
            ValidValueGenerator valueGenerator = new ValidValueGeneratorDate(def);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var value = valueGenerator.GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.IsInstanceOf(typeof(DateTime), value);
            Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value);
        }
예제 #38
0
        public void Test_Register_WhenStdValidValueGenerator_WithValueGen_ShouldReturnWhenResolved()
        {
            //---------------Set up test pack-------------------
            var registry = new ValidValueGeneratorRegistry();

            registry.Register <string>(typeof(ValidValueGeneratorString));
            PropDefFake propDef = new PropDefFake();

            propDef.PropertyType = typeof(string);
            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(string), propDef.PropertyType);
            //---------------Execute Test ----------------------
            ValidValueGenerator boTestFactory = registry.Resolve(propDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ValidValueGeneratorString>(boTestFactory);
        }
예제 #39
0
        public void Test_GenerateValueGreaterThan_WhenIntAndNoRule_ShouldRetValidValue()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };
            ValidValueGeneratorIncrementalInt generator = new ValidValueGeneratorIncrementalInt(def);

            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(int), def.PropertyType);
            Assert.IsEmpty(def.PropRules.OfType <PropRuleInteger>().ToList());
            //---------------Execute Test ----------------------
            int value = (int)generator.GenerateValidValueGreaterThan(int.MaxValue - 5);

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, int.MaxValue - 5);
        }
예제 #40
0
        public void Test_GenerateValidValue_WhenLookupListNull_ShouldRetNull()
        {
            //---------------Set up test pack-------------------
            Type     propertyType = typeof(string);
            IPropDef def          = new PropDefFake
            {
                PropertyType = propertyType
            };

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf <NullLookupList>(def.LookupList);
            //---------------Execute Test ----------------------
            object generateValidValue = new ValidValueGeneratorLookupList(def).GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNull(generateValidValue);
        }
 public void Test_GenerateValue_WhenSecondTime_WhenConstructedAgain_WhenNoRule_ShouldRetOne()
 {
     IPropDef def = new PropDefFake
     {
         PropertyType = typeof(int)
     };
     ValidValueGenerator valueGenerator = new ValidValueGeneratorIncrementalInt(def);
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     object firstValue = valueGenerator.GenerateValidValue();
     object secondValue = new ValidValueGeneratorIncrementalInt(def).GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(secondValue);
     Assert.IsInstanceOf(typeof(int), secondValue);
     Assert.AreEqual(1, secondValue);
     Assert.AreNotEqual(firstValue, secondValue);
 }
        public void Test_GenerateValue_WhenString_ShouldSet()
        {
            //---------------Set up test pack-------------------
            Type     propertyTypeString = typeof(string);
            IPropDef def = new PropDefFake
            {
                PropertyType = propertyTypeString
            };
            var valueGenerator = CreateNameValidValueGenerator(def, GetCompanyNames());
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var value = valueGenerator.GenerateValidValue();

            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.IsInstanceOf(propertyTypeString, value);
        }
 public void Test_GenerateValue_WhenDateTimeAndRule_ShouldRetValidValue()
 {
     IPropDef def = new PropDefFake {
         PropertyType = typeof(DateTime)
     };
     var min = RandomValueGen.GetAbsoluteMin<DateTime>().AddDays(5555.0);
     var max = RandomValueGen.GetAbsoluteMin<DateTime>().AddDays(5565.0);
     def.AddPropRule(CreatePropRuleDate(min, max));
     ValidValueGenerator generator = new ValidValueGeneratorDate(def);
     Assert.AreSame(typeof(DateTime), def.PropertyType);
     Assert.IsNotEmpty(def.PropRules.OfType<PropRuleDate>().ToList());
     PropRuleDate propRule = def.PropRules.OfType<PropRuleDate>().First();
     Assert.AreEqual(min, propRule.MinValue);
     Assert.AreEqual(max.AddDays(1.0).AddMilliseconds(-1.0), propRule.MaxValue);
     var value = (DateTime) generator.GenerateValidValue();
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, min);
     Assert.LessOrEqual(value, max);
 }
        public void Test_GenerateValue_WhenIntAndRule_ShouldRetValidValue()
        {            
            //---------------Set up test pack-------------------

            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };
            def.AddPropRule(CreatePropRuleInt(3, 7));
            ValidValueGenerator generator = new ValidValueGeneratorInt(def);
            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(int), def.PropertyType);
            Assert.IsNotEmpty(def.PropRules.OfType<PropRuleInteger>().ToList());
            PropRuleInteger propRule = def.PropRules.OfType<PropRuleInteger>().First();
            Assert.AreEqual(3, propRule.MinValue);
            Assert.AreEqual(7, propRule.MaxValue);
            int value = (int)generator.GenerateValidValue();
            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, 3);
            Assert.LessOrEqual(value, 7);
        }
 public void Test_GenerateValueGreaterThan_WhenShortAndRule_LtNull_ShouldRetValidValueUsingRules()
 {
     IPropDef def = new PropDefFake {
                                        PropertyType = typeof(short)
                                    };
     const short minValue = 3;
     const short maxValue = 20;
     def.AddPropRule(CreatePropRuleShort(minValue, maxValue));
     var generator = CreateValidValueGenerator(def);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(short), def.PropertyType);
     Assert.IsNotEmpty(def.PropRules.OfType<PropRuleShort>().ToList());
     PropRuleShort propRule = def.PropRules.OfType<PropRuleShort>().First();
     Assert.AreEqual(minValue, propRule.MinValue);
     Assert.AreEqual(maxValue, propRule.MaxValue);
     //---------------Execute Test ----------------------
     var value = (short)generator.GenerateValidValueGreaterThan(null);
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, minValue);
     Assert.LessOrEqual(value,maxValue);
 }
 public void Test_GenerateValue_WhenDateTimeAndRule_ShouldRetValidValue()
 {
     //---------------Set up test pack-------------------
     IPropDef def = new PropDefFake {
         PropertyType = typeof(DateTime)
     };
     var min = RandomValueGen.GetAbsoluteMin<DateTime>().AddDays(5555.0);
     var max = RandomValueGen.GetAbsoluteMin<DateTime>().AddDays(5565.0);
     def.AddPropRule(CreatePropRuleDate(min, max));
     ValidValueGenerator 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, propRule.MaxValue.Date);
     //---------------Execute Test ----------------------
     var value = (DateTime)generator.GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, min);
     Assert.LessOrEqual(value, max);
 }
 public void Test_GenerateValidValue_WhenPropTypeString_ShouldRetItemInList()
 {
     //---------------Set up test pack-------------------
     Type propertyType = typeof(string);
     IPropDef def = new PropDefFake
     {
         PropertyType = propertyType
     };
     var dictionary = new Dictionary<string, string>
                                 {
                                     {"fda", "fdafasd"},
                                     {"fdadffasdf", "gjhj"}
                                 };
     def.LookupList = new SimpleLookupList(dictionary);
     //---------------Assert Precondition----------------
     Assert.IsNotNull(def.LookupList);
     Assert.AreEqual(2, def.LookupList.GetLookupList().Count);
     //---------------Execute Test ----------------------
     object value = new ValidValueGeneratorLookupList(def).GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.IsInstanceOf(typeof(string), value);
     StringAssert.StartsWith("fda", value.ToString());
 }
 public void Test_GenerateValidValue_WhenPropTypeGuid_ShouldReturnItemInListAsGuid()
 {
     //---------------Set up test pack-------------------
     Type guidPropType = typeof(Guid);
     IPropDef def = new PropDefFake
     {
         PropertyType = guidPropType
     };
     RandomValueGen.GetRandomGuid().ToString();
     var dictionary = new Dictionary<string, string>
                                 {
                                     {"fdafasd", RandomValueGen.GetRandomGuid().ToString()}
                                 };
     def.LookupList = new SimpleLookupList(dictionary);
     //---------------Assert Precondition----------------
     Assert.IsNotNull(def.LookupList);
     Assert.AreEqual(1, def.LookupList.GetLookupList().Count);
     Assert.AreSame(guidPropType, def.PropertyType);
     //---------------Execute Test ----------------------
     object value = new ValidValueGeneratorLookupList(def).GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.IsInstanceOf(guidPropType, value, value + " should be of type guid");
 }
        public void Test_GenerateValueLessThan_WhenIntAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue()
        {
            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };
            const int minValue = 3;
            const int maxValue = 5;
            const int lessThanValue = int.MaxValue - 77;

            def.AddPropRule(CreatePropRuleInt(minValue, maxValue));
            ValidValueGeneratorIncrementalInt generator = new ValidValueGeneratorIncrementalInt(def);
            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(int), def.PropertyType);
            Assert.IsNotEmpty(def.PropRules.OfType<PropRuleInteger>().ToList());
            PropRuleInteger propRule = def.PropRules.OfType<PropRuleInteger>().First();
            Assert.AreEqual(minValue, propRule.MinValue);
            Assert.AreEqual(maxValue, propRule.MaxValue);
            //---------------Execute Test ----------------------
            int value = (int)generator.GenerateValidValueLessThan(lessThanValue);
            //---------------Test Result -----------------------
            Assert.IsNotNull(value);
            Assert.GreaterOrEqual(value, minValue);
            Assert.LessOrEqual(value, lessThanValue);
            Assert.LessOrEqual(value, maxValue);
        }
 public void Test_GetValidValueGenerator_WhenHasLookup_ShouldRetLookupGenerator()
 {
     //---------------Set up test pack-------------------
     IPropDef def = new PropDefFake 
             {
                 PropertyType = typeof(string),
                 LookupList = MockRepository.GenerateStub<IBusinessObjectLookupList>()
             };
     //---------------Assert Precondition----------------
     Assert.IsTrue(def.HasLookupList());
     //---------------Execute Test ----------------------
     var generator = new BOTestFactory<FakeBOWithRules>().GetValidValueGenerator(def);
     //---------------Test Result -----------------------
     Assert.IsNotNull(generator);
     Assert.IsInstanceOf<ValidValueGeneratorLookupList>(generator);
 }
 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_GenerateValueLessThan_WhenDateTimeAndRule_WhenRuleMoreRestrictive_ShouldRetValidValue()
 {
     //---------------Set up test pack-------------------
     IPropDef def = new PropDefFake {
         PropertyType = typeof(DateTime)
     };
     var min = DateTime.Now;
     var max = DateTime.Today.AddDays(5.0);
     var overridingMaxValue = RandomValueGen.GetAbsoluteMax<DateTime>().AddDays(-5.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.GenerateValidValueLessThan(overridingMaxValue);
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, min);
     Assert.LessOrEqual(value, max);
     Assert.LessOrEqual(value, overridingMaxValue);
 }
        public void Test_GenerateValue_WhenIntAndRule_AndNextValGTMaxVal_ShouldRestartAtMin()
        {            
            //---------------Set up test pack-------------------

            IPropDef def = new PropDefFake {
                PropertyType = typeof(int)
            };
            const int minValue = 3;
            const int maxValue = 4;
            def.AddPropRule(CreatePropRuleInt(minValue, maxValue));
            ValidValueGenerator generator = new ValidValueGeneratorIncrementalInt(def);
            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(int), def.PropertyType);
            Assert.IsNotEmpty(def.PropRules.OfType<PropRuleInteger>().ToList());
            PropRuleInteger propRule = def.PropRules.OfType<PropRuleInteger>().First();
            Assert.AreEqual(minValue, propRule.MinValue);
            Assert.AreEqual(maxValue, propRule.MaxValue);
            //---------------Execute Test ----------------------
            var value1 = (int)generator.GenerateValidValue();
            var value2 = (int)generator.GenerateValidValue();
            int value3 = (int)generator.GenerateValidValue();
            //---------------Test Result -----------------------
            Assert.AreEqual(minValue, value1);
            Assert.AreEqual(maxValue, value2);
            Assert.AreEqual(minValue, value3);
        }
 public void Test_GenerateValueLessThan_WhenDateTimeAndNoRule_ShouldRetValidValue()
 {
     // Redmine #1745
     // Changed from using DateTime.MinValue as Sql Server can't handle this
     // Sql Server min date is 1/1/1753
     //---------------Set up test pack-------------------
     var expectedAbsoluteMin = new DateTime(1753, 1, 1);
     IPropDef def = new PropDefFake {
         PropertyType = typeof(DateTime)
     };
     var generator = new ValidValueGeneratorDate(def);
     var overridingMaxValue = expectedAbsoluteMin.AddDays(7.0);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(DateTime), def.PropertyType);
     Assert.IsEmpty(def.PropRules.OfType<PropRuleDate>().ToList());
     //---------------Execute Test ----------------------
     var value = (DateTime)generator.GenerateValidValueLessThan(overridingMaxValue);
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, expectedAbsoluteMin);
     Assert.LessOrEqual(value, overridingMaxValue);
 }
 public void Test_GenerateValueLessThan_WhenIntAndNoRule_ShouldRetValidValue()
 {
     IPropDef def = new PropDefFake {
         PropertyType = typeof(int)
     };
     ValidValueGeneratorIncrementalInt generator = new ValidValueGeneratorIncrementalInt(def);
     const int lessThanValue = int.MinValue + 10;
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(int), def.PropertyType);
     Assert.IsEmpty(def.PropRules.OfType<PropRuleInteger>().ToList());
     //---------------Execute Test ----------------------
     int value = (int)generator.GenerateValidValueLessThan(lessThanValue);
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, int.MinValue);
     Assert.LessOrEqual(value, lessThanValue);
 }
 public void Test_GenerateValueLessThan_WhenIntAndRule_LtNull_ShouldRetValidValueUsingRules()
 {
     IPropDef def = new PropDefFake {
                                        PropertyType = typeof(long)
                                    };
     const int maxValue = int.MaxValue - 77;
     const int minValue = 3;
     def.AddPropRule(CreatePropRuleLong(minValue,maxValue));
     ValidValueGeneratorLong generator = new ValidValueGeneratorLong(def);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(long), def.PropertyType);
     Assert.IsNotEmpty(def.PropRules.OfType<PropRuleLong>().ToList());
     PropRuleLong propRule = def.PropRules.OfType<PropRuleLong>().First();
     Assert.AreEqual(minValue, propRule.MinValue);
     Assert.AreEqual(maxValue, propRule.MaxValue);
     //---------------Execute Test ----------------------
     long value = (long)generator.GenerateValidValueLessThan(null);
     //---------------Test Result -----------------------
     Assert.IsNotNull(value);
     Assert.GreaterOrEqual(value, minValue);
     Assert.LessOrEqual(value, maxValue);
 }
 public void Test_GenerateValue_WhenSecondTime_WhenNoRule_WhenDiffPropDef_ShouldRetZero()
 {
     //Each Prop Def should have its own incremental value. Otherwise would get continued reseting with
     // each having a different Set of rules (i.e Min and Max).
     IPropDef def1 = new PropDefFake
     {
         PropertyType = typeof(int)
     };
     IPropDef def2 = new PropDefFake
     {
         PropertyType = typeof(int)
     };
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     new ValidValueGeneratorIncrementalInt(def1).GenerateValidValue();
     object secondValue = new ValidValueGeneratorIncrementalInt(def2).GenerateValidValue();
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(int), secondValue);
     Assert.AreEqual(0, secondValue);
 }
 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);
 }
 public void Test_GetValidValueGenerator_WhenEnum_ShouldRetEnumGenerator()
 {
     //---------------Set up test pack-------------------
     IPropDef def = new PropDefFake 
             {
                 PropertyType = typeof(FakeEnum)
             };
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var generator = new BOTestFactory<FakeBOWithRules>().GetValidValueGenerator(def);
     //---------------Test Result -----------------------
     Assert.IsNotNull(generator);
     Assert.IsInstanceOf<ValidValueGeneratorEnum>(generator);
 }