当前位置: 首页>>代码示例>>C#>>正文


C# PropDef.IsValueValid方法代码示例

本文整理汇总了C#中PropDef.IsValueValid方法的典型用法代码示例。如果您正苦于以下问题:C# PropDef.IsValueValid方法的具体用法?C# PropDef.IsValueValid怎么用?C# PropDef.IsValueValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropDef的用法示例。


在下文中一共展示了PropDef.IsValueValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_IsValueValid_TwoPropRule_InValidValue_FirstRulePass_FirstRuleFail

        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);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:19,代码来源:TestPropDef.cs

示例2: Test_IsValueValid_TwoPropRule_ValidValue

        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);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:18,代码来源:TestPropDef.cs

示例3: Test_IsValueValid_ValueInLookupList_Int

        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);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:20,代码来源:TestPropDef.cs

示例4: Test_IsValueValid_ValueNotInLookupList_Int

        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);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:22,代码来源:TestPropDef.cs

示例5: Test_IsValueValid_ValueInLookupList_Guid

        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);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:20,代码来源:TestPropDef.cs


注:本文中的PropDef.IsValueValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。