예제 #1
0
        public void RuleDebuggerTest()
        {
            var cnlSentences = new List <string>()
            {
                "John is a man.",
                "Mary is a woman.",
                "John has-friend Mary.",
                "Mary has-name equal-to 'Mary'.",
                "If a man has-friend a woman and the woman has-name equal-to 'Mary' then the man is an happy-man."
            };
            var feClient = new CogniPySvr();
            var ruleId   = feClient.GetStatementId(cnlSentences[4]);

            feClient.SetDebugListener((statementId, elements) =>
            {
                Assert.AreEqual(ruleId, statementId);
                Assert.AreEqual(2, elements.Count());
                Assert.AreEqual("John", elements[0].Value.ToString());
                Assert.AreEqual("man", elements[0].Name);
                Assert.AreEqual("Mary", elements[1].Value.ToString());
                Assert.AreEqual("woman", elements[1].Name);
            }, (s, c) => Tuple.Create(s, c));
            feClient.LoadCnlFromString(string.Join("\r\n", cnlSentences), true, true);
        }