public void OneLine_Format_Success()
        {
            var conditions = new Condition[]
            {
                new Condition("condition 1"),
                new Condition("condition 2"),
            };

            string expected = @"(op(condition 1)(condition 2))";

            Assert.Equal(expected, _oneLine.Format(new CombinatoryCondition("op", conditions)));
        }
Exemple #2
0
        public override string Format(Defrule rule, IConditionFormat conditionFormat)
        {
            var output = new StringBuilder("(defrule");

            foreach (var condition in rule.Conditions)
            {
                foreach (var line in conditionFormat.Format(condition).Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    output.Append($"{LineSeparator}{Indentation}{line}");
                }
            }
            output.Append($"{LineSeparator}=>");
            foreach (var action in rule.Actions)
            {
                output.Append($"{LineSeparator}{Indentation}({action.Text})");
            }
            output.Append($"{LineSeparator})");
            return(output.ToString());
        }
Exemple #3
0
 public override string Format(Defrule rule, IConditionFormat conditionFormat)
 {
     return($"(defrule{string.Join(string.Empty, rule.Conditions.Select(x => conditionFormat.Format(x)))}=>{string.Join(string.Empty, rule.Actions)})");
 }
 public void Parse_Success(string text, string expected)
 {
     Assert.Equal(expected, _format.Format(Condition.Parse(text)));
 }