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


C# RuleSet.Validate方法代码示例

本文整理汇总了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;
        }
开发者ID:Dan-Landberg,项目名称:HurfDurf-Sample-Rule-Engine,代码行数:28,代码来源:Unit.cs

示例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");
        }
开发者ID:Dan-Landberg,项目名称:HurfDurf-Sample-Rule-Engine,代码行数:13,代码来源:RuleSetTests.cs

示例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");
        }
开发者ID:Dan-Landberg,项目名称:HurfDurf-Sample-Rule-Engine,代码行数:13,代码来源:RuleSetTests.cs

示例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");
        }
开发者ID:Dan-Landberg,项目名称:HurfDurf-Sample-Rule-Engine,代码行数:15,代码来源:UnderMaximumIdealRangeRuleTest.cs

示例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");
        }
开发者ID:Dan-Landberg,项目名称:HurfDurf-Sample-Rule-Engine,代码行数:15,代码来源:UnderMaximumRangeRuleTests.cs

示例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");
        }
开发者ID:Dan-Landberg,项目名称:HurfDurf-Sample-Rule-Engine,代码行数:15,代码来源:OverMinimumIdealRangeRule.cs


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