public void ShouldBePossibleEvaluateRuleAndFireExpressionListener()
        {
            var rule = new Rule();

            rule.Name = "fake.rule";

            rule.AddListener <IDictionary <string, object> >((o) =>
            {
                o["Email"] = "*****@*****.**";
            });

            var filter = rule.AddAndFilter();

            filter.Add(new EqualsConstraint("Name", "John Doe"));

            this.AddRule(rule);

            var data = new Dictionary <string, object>();

            data["Name"] = "John Doe";

            this.Engine.EvaluateAndFire(data);

            Assert.Equal("*****@*****.**", data["Email"]);
        }
Exemplo n.º 2
0
        public void ShouldBePossibleEvaluateRuleAndFireListener()
        {
            var rule = new Rule();

            rule.Name = "fake.rule";
            rule.AddListener(new FakeRuleListener());

            var filter = rule.AddAndFilter();

            filter.Add(new EqualsConstraint("Name", "John Doe"));

            this.AddRule(rule);

            var data = new Dictionary <string, object>();

            data["Name"] = "John Doe";

            this.Engine.EvaluateAndFire(data);

            Assert.Equal(true, data["Changed"]);
        }