本文整理汇总了C#中RuleSet.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# RuleSet.Validate方法的具体用法?C# RuleSet.Validate怎么用?C# RuleSet.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuleSet
的用法示例。
在下文中一共展示了RuleSet.Validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fire
public string Fire(Unit target)
{
string result = string.Empty;
RuleSet idealHitRules = new RuleSet();
idealHitRules.Add(new UnderMaximumIdealRangeRule(this, target));
idealHitRules.Add(new OverMinimumIdealRangeRule(this, target));
RuleSet regularHitRules = new RuleSet();
regularHitRules.Add(new UnderMaximumRangeRule(this, target));
regularHitRules.Add(new OverMinimumRangeRule(this, target));
//Fire!
if (idealHitRules.Validate())
{
result = "Ideal hit!";
}
else if (regularHitRules.Validate())
{
result = "Hit.";
}
else
{
result = regularHitRules.FailureMessages[0];
}
return result;
}
示例2: RuleSetSuccess
public void RuleSetSuccess()
{
//Assemble
RuleSet rules = new RuleSet();
rules.Add(new StringMatchRule(){ string1 = "One", string2 = "One" });
//Act
bool success = rules.Validate();
//Assert
Assert.IsTrue(success, "Strings did not match");
Assert.IsEmpty(rules.FailureMessages, "There should not be any FailureMessages");
}
示例3: RuleSetFailure
public void RuleSetFailure()
{
//Assemble
RuleSet rules = new RuleSet();
rules.Add(new StringMatchRule() { string1 = "Two", string2 = "Hats" });
//Act
bool success = rules.Validate();
//Assert
Assert.IsFalse(success, "No match should exist");
Assert.IsNotEmpty(rules.FailureMessages, "There should not be any FailureMessages");
}
示例4: PassMaxIdealRangeTest
public void PassMaxIdealRangeTest()
{
//Assemble
Unit unit1 = new Unit() { MaximumIdealRange = 10, XCoordinate = 0, YCoordinate = 0 };
Unit unit2 = new Unit() { MaximumIdealRange = 10, XCoordinate = 0, YCoordinate = 5 };
RuleSet rules = new RuleSet();
rules.Add(new UnderMaximumIdealRangeRule(unit1, unit2));
//Act
bool success = rules.Validate();
//Assert
Assert.IsTrue(success, "Unit should be inside of max ideal range");
}
示例5: FailMaxRangeTest
public void FailMaxRangeTest()
{
//Assemble
Unit unit1 = new Unit() { MaximumRange = 10, XCoordinate = 0, YCoordinate = 0 };
Unit unit2 = new Unit() { MaximumRange = 10, XCoordinate = 0, YCoordinate = 500 };
RuleSet rules = new RuleSet();
rules.Add(new UnderMaximumRangeRule(unit1, unit2));
//Act
bool success = rules.Validate();
//Assert
Assert.IsFalse(success, "Unit should be outside of max range");
}
示例6: FailMinIdealRangeTest
public void FailMinIdealRangeTest()
{
//Assemble
Unit unit1 = new Unit() { MinimumIdealRange = 10, XCoordinate = 0, YCoordinate = 0 };
Unit unit2 = new Unit() { MinimumIdealRange = 10, XCoordinate = 0, YCoordinate = 5 };
RuleSet rules = new RuleSet();
rules.Add(new OverMinimumIdealRangeRule(unit1, unit2));
//Act
bool success = rules.Validate();
//Assert
Assert.IsFalse(success, "Unit should be inside of min ideal range");
}