Exemplo n.º 1
0
        public void TestSingleRule()
        {
            PropRuleSingle rule = new PropRuleSingle("num", "TestMessage", 5.32f, 10.11111f);

            string errorMessage = "";

            //Test less than min
            Assert.IsFalse(rule.IsPropValueValid("Propname", 5.31116f, ref errorMessage));
            Assert.IsTrue(errorMessage.Length > 0);
            //Test valid data
            Assert.IsTrue(rule.IsPropValueValid("Propname", 6, ref errorMessage));
            Assert.IsFalse(errorMessage.Length > 0);
            //test greater than max
            Assert.IsFalse(rule.IsPropValueValid("Propname", 10.1111112f, ref errorMessage));
            Assert.IsTrue(errorMessage.Length > 0);

            rule         = new PropRuleSingle("num", "TestMessage", 5.32f, 10.11111f);
            errorMessage = "";

            Assert.IsTrue(rule.IsPropValueValid("Propname", null, ref errorMessage));
            Assert.IsTrue(errorMessage.Length == 0);
            errorMessage = "";
            Assert.IsFalse(rule.IsPropValueValid("Propname", -53444.33222f, ref errorMessage));
            Assert.IsTrue(errorMessage.Length > 0);
        }
Exemplo n.º 2
0
        public void TestSingleRule()
        {
            PropRuleSingle rule = new PropRuleSingle("num", "TestMessage", 5.32f, 10.11111f);

            string errorMessage = "";

            //Test less than min
            Assert.IsFalse(rule.IsPropValueValid("Propname", 5.31116f, ref errorMessage));
            Assert.IsTrue(errorMessage.Length > 0);
            //Test valid data
            Assert.IsTrue(rule.IsPropValueValid("Propname", 6, ref errorMessage));
            Assert.IsFalse(errorMessage.Length > 0);
            //test greater than max
            Assert.IsFalse(rule.IsPropValueValid("Propname", 10.1111112f, ref errorMessage));
            Assert.IsTrue(errorMessage.Length > 0);

            rule = new PropRuleSingle("num", "TestMessage", 5.32f, 10.11111f);
            errorMessage = "";

            Assert.IsTrue(rule.IsPropValueValid("Propname", null, ref errorMessage));
            Assert.IsTrue(errorMessage.Length == 0);
            errorMessage = "";
            Assert.IsFalse(rule.IsPropValueValid("Propname", -53444.33222f, ref errorMessage));
            Assert.IsTrue(errorMessage.Length > 0);
        }
Exemplo n.º 3
0
        public void Test_PropRuledateMax_ViaInterface()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            const float minValue = Single.MinValue;
            const float maxValue = Single.MaxValue;
            IPropRuleComparable<Single> rule =
               new PropRuleSingle("fdsafasd", "Test", minValue, maxValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(minValue, rule.MinValue);
            Assert.AreEqual(maxValue, rule.MaxValue);
        }
Exemplo n.º 4
0
        public void Test_PropRuledateMax_ViaInterface()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            const float minValue = Single.MinValue;
            const float maxValue = Single.MaxValue;
            IPropRuleComparable <Single> rule =
                new PropRuleSingle("fdsafasd", "Test", minValue, maxValue);

            //---------------Test Result -----------------------
            Assert.AreEqual(minValue, rule.MinValue);
            Assert.AreEqual(maxValue, rule.MaxValue);
        }