public void KnowledgeTest_GetImplicationChain() { var target = new KnowledgeStore(); target.AddAttribute(new KnowledgeAttribute { Attribute = "cat", Subject = "Pixel" }, new HashSet <string> { "test" }); target.AddImplication(new KnowledgeImplication { Implicator = "cat", Implied = "animal" }, new HashSet <string> { "test" }); target.AddImplication(new KnowledgeImplication { Implicator = "animal", Implied = "object" }, new HashSet <string> { "test" }); var actual = target.GetImplicationChain("Pixel", "object"); var expected = new List <string> { "cat", "animal", "object" }; Assert.AreEqual(3, actual.Count); for (int i = 0; i < actual.Count; i++) { Assert.AreEqual(expected[i], actual[i]); } }
public void KnowledgeTest_RelationImplicationChainingFamily() { var target = new KnowledgeStore(); target.AddAttribute(new KnowledgeAttribute { Attribute = "cat", Subject = "Pixel" }, new HashSet <string> { "test" }); target.AddAttribute(new KnowledgeAttribute { Attribute = "cat", Subject = "Tiger" }, new HashSet <string> { "test" }); target.AddRelation(new KnowledgeRelation { Relation = "brotherof", Subject = "Tiger", Target = "Pixel" }, new HashSet <string> { "test" }); target.AddImplication(new KnowledgeImplication { Implicator = "brotherof", Implied = "siblingof" }, new HashSet <string> { "test" }); target.AddImplication(new KnowledgeImplication { Implicator = "siblingof", Implied = "familyof" }, new HashSet <string> { "test" }); var actual = target.ListAllRelated("familyof", "Pixel"); Assert.AreEqual(1, actual.Count); Assert.AreEqual("Tiger", actual.Single()); }
public void KnowledgeTest_GetImplicationChainDirectHit() { var target = new KnowledgeStore(); target.AddAttribute(new KnowledgeAttribute { Attribute = "cat", Subject = "Pixel" }, new HashSet <string> { "test" }); target.AddImplication(new KnowledgeImplication { Implicator = "animal", Implied = "object" }, new HashSet <string> { "test" }); var actual = target.GetImplicationChain("Pixel", "cat"); Assert.AreEqual(1, actual.Count); Assert.AreEqual("cat", actual.First()); }