Exemplo n.º 1
0
        public void RuleControllerTest_AddRule()
        {
            var expected = service.Add(new RuleModel());
            var actual   = controller.AddRule(new RuleModel());

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        internal void LoadController(XmlNodeList xmlNodeList, RuleController ruleController)
        {
            foreach (XmlNode xmlMainNode in xmlNodeList)
            {
                if (xmlMainNode.Name.Equals("Rule"))
                {
                    //We got our hands on a rule, lets load it.
                    var rule = new Rule();
                    foreach (XmlNode childNode in xmlMainNode)
                    {
                        switch (childNode.Name)
                        {
                        case "Name":
                            rule.Name = childNode.InnerText;
                            break;

                        case "Script":
                            rule.Script = childNode.InnerText;
                            break;

                        case "MatchAll":
                            rule.MatchAll = Convert.ToBoolean(childNode.InnerText);
                            break;

                        case "ShouldTarget":
                            rule.ShouldTarget =
                                (Target)Enum.Parse(typeof(Target), childNode.InnerText);
                            break;

                        case "Priority":
                            rule.Priority = Convert.ToInt32(childNode.InnerText);
                            break;

                        case "Action":
                            rule.LoadAction(childNode);
                            break;

                        default:
                            AbstractCondition condition = LoadConditions(childNode);
                            if (condition != null)
                            {
                                rule.AddCondition(condition);
                            }
                            break;
                        }
                    }
                    ruleController.AddRule(rule);
                }
            }
        }
Exemplo n.º 3
0
        public void Add_Rules_Null_Input_Test()
        {
            IActionResult result = _RuleController.AddRule(null);

            Assert.True(result.GetType() == typeof(BadRequestObjectResult));
        }