예제 #1
0
        public void AddTriggeredRule(string assertion)
        {
            var fact = new Fact()
            {
                Assertion = assertion
            };
            var precondition = new ContainsPrecondition.Builder().WithFact(fact).Build();
            var rule         = new Rule.Builder().Build();

            rule.AddPrecondition(precondition);
            rule.MarkAsTriggered();

            _ruleBase.AddRule(rule);
        }
        private RuleBase SeedRuleBase(bool withMatch = true)
        {
            var assertion = withMatch ? "Has .NET" : "Has no .NET";

            var ruleBase = new RuleBase.Builder().Build();

            var rule = new Rule(Guid.Empty);
            var fact = new Fact()
            {
                Assertion = assertion
            };
            var precondition = new ContainsPrecondition.Builder()
                               .WithFact(fact)
                               .Build();

            rule.AddPrecondition(precondition);

            var action1 = new AddRuleAction();

            action1.SetFact(new Fact()
            {
                Assertion = "Potential C# experience"
            });

            var action2 = new AddRuleAction();

            action2.SetFact(new Fact()
            {
                Assertion = "Potential Angular experience"
            });

            rule.AddRuleAction(action1);
            rule.AddRuleAction(action2);

            ruleBase.AddRule(rule);

            return(ruleBase);
        }