public void testEvaluateWithInternationalCharset() { string path = "中 文 <that> * <topic> *"; string template = "中文 (Chinese)"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); string path2 = "日 本 語 <that> * <topic> *"; string template2 = "日 本 語 (Japanese)"; this.mockNode.addCategory(path2, template2, "filename"); string path3 = "Русский язык <that> * <topic> *"; string template3 = "Русский язык (Russian)"; this.mockNode.addCategory(path3, template3, "filename"); this.mockRequest = new Request("中 文", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("中文 (Chinese)", this.mockNode.evaluate("中 文 <that> * <topic> *", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); this.mockRequest = new Request("日 本 語", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("日 本 語 (Japanese)", this.mockNode.evaluate("日 本 語 <that> * <topic> *", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); this.mockRequest = new Request("Русский язык", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("Русский язык (Russian)", this.mockNode.evaluate("Русский язык <that> * <topic> *", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); }
public void testEvaluateWithMultipleWildcardsSwitched() { string path = "Test * 1 _ <that> Test * 1 _ <topic> Test _ 1 *"; string template = "<srai>TEST</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); string pathAlt = "Alt Test <that> that <topic> topic"; string templateAlt = "<srai>TEST ALT</srai>"; this.mockNode.addCategory(pathAlt, templateAlt, "filename"); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test FIRST USER 1 SECOND USER <that> Test FIRST THAT 1 SECOND THAT <topic> Test FIRST TOPIC 1 SECOND TOPIC", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); Assert.AreEqual(2, this.mockQuery.InputStar.Count); Assert.AreEqual("SECOND USER", (string)this.mockQuery.InputStar[0]); Assert.AreEqual("FIRST USER", (string)this.mockQuery.InputStar[1]); Assert.AreEqual(2, this.mockQuery.ThatStar.Count); Assert.AreEqual("SECOND THAT", (string)this.mockQuery.ThatStar[0]); Assert.AreEqual("FIRST THAT", (string)this.mockQuery.ThatStar[1]); Assert.AreEqual(2, this.mockQuery.TopicStar.Count); Assert.AreEqual("SECOND TOPIC", (string)this.mockQuery.TopicStar[0]); Assert.AreEqual("FIRST TOPIC", (string)this.mockQuery.TopicStar[1]); }
public void testEvaluateTimeOut() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.GlobalSettings.addSetting("timeout", "10"); this.mockNode = new AIMLbot.Utils.Node(); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); string path = "Test 1 <that> that <topic> topic"; string template = "<srai>TEST</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); string pathAlt = "Alt Test <that> that <topic> topic"; string templateAlt = "<srai>TEST ALT</srai>"; this.mockNode.addCategory(pathAlt, templateAlt, "filename"); this.mockQuery = new AIMLbot.Utils.SubQuery(path); System.Threading.Thread.Sleep(20); string result = this.mockNode.evaluate("Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()); Assert.AreEqual(string.Empty, result); Assert.AreEqual(true, this.mockRequest.hasTimedOut); }
public void setupMockObjects() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.GlobalSettings.addSetting("timeout", "9999999999"); this.mockNode = new AIMLbot.Utils.Node(); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery("Test 1 <that> * <topic> *"); }
public void testEvaluateWithEmptyNode() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockNode = new AIMLbot.Utils.Node(); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery("Test 1 <that> that <topic> topic"); Assert.AreEqual(string.Empty, this.mockNode.evaluate("Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); }
public void testEvaluateWithNoWildCards() { string path = "Test 1 <that> that <topic> topic"; string template = "<srai>TEST</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); }
public void testAddCategoryWithGoodData() { string path = "Test 1 <that> * <topic> *"; string template = "<srai>Test</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); Assert.AreEqual(1,this.mockNode.NumberOfChildNodes); Assert.AreEqual(string.Empty, this.mockNode.filename); Assert.AreEqual(string.Empty, this.mockNode.template); Assert.AreEqual(string.Empty, this.mockNode.word); }
public void testAddCategoryWithGoodData() { string path = "Test 1 <that> * <topic> *"; string template = "<srai>Test</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); Assert.AreEqual(1, this.mockNode.NumberOfChildNodes); Assert.AreEqual(string.Empty, this.mockNode.filename); Assert.AreEqual(string.Empty, this.mockNode.template); Assert.AreEqual(string.Empty, this.mockNode.word); }
public void testEvaluateWithStarWildCardThat() { string path = "Test 1 <that> Test * 1 <topic> topic"; string template = "<srai>TEST</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); string pathAlt = "Alt Test <that> that <topic> topic"; string templateAlt = "<srai>TEST ALT</srai>"; this.mockNode.addCategory(pathAlt, templateAlt, "filename"); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test 1 <that> Test WILDCARD WORDS 1 <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); Assert.AreEqual("WILDCARD WORDS", (string)this.mockQuery.ThatStar[0]); }
public void testEvaluateWith_WildCardUserInput() { string path = "_ Test 1 <that> that <topic> topic"; string template = "<srai>TEST</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); string pathAlt = "Alt Test <that> that <topic> topic"; string templateAlt = "<srai>TEST ALT</srai>"; this.mockNode.addCategory(pathAlt, templateAlt, "filename"); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("WILDCARD WORDS Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); Assert.AreEqual("WILDCARD WORDS", (string)this.mockQuery.InputStar[0]); }
public void testEvaluateWithWildcardsInDifferentPartsOfPath() { string path = "Test * 1 <that> Test * 1 <topic> Test * 1"; string template = "<srai>TEST</srai>"; this.mockNode = new AIMLbot.Utils.Node(); this.mockNode.addCategory(path, template, "filename"); string pathAlt = "Alt Test <that> that <topic> topic"; string templateAlt = "<srai>TEST ALT</srai>"; this.mockNode.addCategory(pathAlt, templateAlt, "filename"); this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot); this.mockQuery = new AIMLbot.Utils.SubQuery(path); Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test WILDCARD USER WORDS 1 <that> Test WILDCARD THAT WORDS 1 <topic> Test WILDCARD TOPIC WORDS 1", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder())); Assert.AreEqual("WILDCARD USER WORDS", (string)this.mockQuery.InputStar[0]); Assert.AreEqual("WILDCARD THAT WORDS", (string)this.mockQuery.ThatStar[0]); Assert.AreEqual("WILDCARD TOPIC WORDS", (string)this.mockQuery.TopicStar[0]); }