Ejemplo n.º 1
0
        public void TestIsRequiredValdiation()
        {
            //---------------Set up test pack-------------------
            const string   myString = "Hello";
            ValidationRule testRule = new ValidationRule();

            testRule.IsRequired = true;

            //---------------Execute Test ----------------------
            bool result = ValidationUtil.CompareValues(myString, "", testRule.Operator, testRule.DataType);

            //---------------Test Result -----------------------
            Assert.IsTrue(result);
        }
Ejemplo n.º 2
0
        public void TestCompareIntegers()
        {
            //---------------Set up test pack-------------------
            const int      firstInt       = 10;
            const int      sameAsFirstInt = 10;
            const int      myInt          = 80;
            ValidationRule testRule       = new ValidationRule();

            testRule.Operator = ValidationCompareOperator.Equal;
            testRule.DataType = ValidationDataType.Integer;
            //-------------Test Preconditions------------------
            Assert.AreEqual(firstInt, sameAsFirstInt);
            //---------------Execute Test ----------------------
            bool result      = ValidationUtil.CompareValues(Convert.ToString(firstInt), Convert.ToString(sameAsFirstInt), testRule.Operator, testRule.DataType);
            bool falseResult = ValidationUtil.CompareValues(Convert.ToString(firstInt), Convert.ToString(myInt), testRule.Operator, testRule.DataType);

            //---------------Test Result -----------------------
            Assert.IsTrue(result);
            Assert.IsFalse(falseResult);
        }
Ejemplo n.º 3
0
        public void TestCompareStrings()
        {
            //---------------Set up test pack-------------------
            const string   firstString       = "FirstString";
            const string   sameAsFirstString = "FirstString";
            const string   myString          = "Hello World";
            ValidationRule testRule          = new ValidationRule();

            testRule.Operator = ValidationCompareOperator.Equal;
            testRule.DataType = ValidationDataType.String;

            //---------Assert Preconditions----------------------
            Assert.IsTrue(String.Equals(firstString, sameAsFirstString));

            //---------------Execute Test ----------------------
            bool result      = ValidationUtil.CompareValues(firstString, sameAsFirstString, testRule.Operator, testRule.DataType);
            bool falseResult = ValidationUtil.CompareValues(firstString, myString, testRule.Operator, testRule.DataType);

            //---------------Test Result -----------------------
            Assert.IsTrue(result);
            Assert.IsFalse(falseResult);
        }