本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}