Esempio n. 1
0
        public void Test_IsValueValid_TwoPropRule_InValidValue_FirstRulePass_FirstRuleFail()
        {
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadOnly, null);
            propDef.AddPropRule(new PropRuleString("StringRule", "Rule 1", 1, 3, ""));
            propDef.AddPropRule(new PropRuleString("StringRule", "Rule 2", 3, 10, ""));

            //---------------Assert Precondition----------------
            Assert.AreEqual(2, propDef.PropRules.Count);

            //---------------Execute Test ----------------------
            string errMsg = "";
            bool valid = propDef.IsValueValid("Long String", ref errMsg);

            //---------------Test Result -----------------------
            Assert.IsFalse(valid);
            StringAssert.Contains("'Long String' for property 'Prop Name' is not valid for the rule 'StringRule'", errMsg);
            StringAssert.Contains("Rule 1", errMsg);
        }
Esempio n. 2
0
        public void Test_IsValueValid_TwoPropRule_ValidValue()
        {
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadOnly, null);
            propDef.AddPropRule(new PropRuleString("StringRule", "Rule 1", 1, 3, ""));
            propDef.AddPropRule(new PropRuleString("StringRule", "Rule 2", 3, 10, ""));

            //---------------Assert Precondition----------------
            Assert.AreEqual(2, propDef.PropRules.Count);

            //---------------Execute Test ----------------------
            string errMsg = "";
            bool valid = propDef.IsValueValid("ABC", ref errMsg);

            //---------------Test Result -----------------------
            Assert.IsTrue(valid);
            Assert.AreEqual("", errMsg);
        }
Esempio n. 3
0
        public void Test_IsValueValid_ValueInLookupList_Int()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            BOWithIntID.LoadClassDefWithIntID();
            PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null) ;
            BOWithIntID validBusinessObject = new BOWithIntID { IntID = 3, TestField = "ValidValue" };
            validBusinessObject.Save();
            propDef.LookupList = new BusinessObjectLookupList(typeof(BOWithIntID));
            //---------------Assert Precondition----------------
            
            //---------------Execute Test ----------------------
            string errMsg = "";
            bool valid = propDef.IsValueValid(validBusinessObject.IntID, ref errMsg);

            //---------------Test Result -----------------------
            Assert.AreEqual("", errMsg);
            Assert.IsTrue(valid);
        }
Esempio n. 4
0
        public void Test_IsValueValid_ValueNotInLookupList_Int()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            BOWithIntID.LoadClassDefWithIntID();
            PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null) { LookupList = new BusinessObjectLookupList(typeof(BOWithIntID), "", "", true) };
            const int invalidValue = 4555;
            //---------------Assert Precondition----------------
            
            //---------------Execute Test ----------------------
            string errMsg = "";
            
            bool valid = propDef.IsValueValid(invalidValue, ref errMsg);

            //---------------Test Result -----------------------

            string expectedErrorMessage = "Prop Name' invalid since '" + invalidValue + "' is not in the lookup list of available values.";
            StringAssert.Contains(expectedErrorMessage, errMsg);
//            StringAssert.Contains();
            Assert.IsFalse(valid);
        }
Esempio n. 5
0
        public void Test_IsValueValid_ValueInLookupList_Guid()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            MyBO.LoadDefaultClassDef();
            PropDef propDef = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null) ;
            MyBO validBusinessObject = new MyBO {TestProp = "ValidValue"};
            validBusinessObject.Save();
            propDef.LookupList = new BusinessObjectLookupList(typeof(MyBO));
            //---------------Assert Precondition----------------
            
            //---------------Execute Test ----------------------
            string errMsg = "";
            bool valid = propDef.IsValueValid(validBusinessObject.ID.GetAsGuid(), ref errMsg);

            //---------------Test Result -----------------------
            Assert.AreEqual("", errMsg);
            Assert.IsTrue(valid);
        }