// This tests the language engine BestDecision method will return the correct index given // a matching second option when using the KMP Comparison. public void LanguageEngineBestDecisionPassesGivenSecondMatchKMPcomp() { LangE = new GameObject(); LangE.AddComponent <LanguageEngine>(); Leng = LangE.GetComponent <LanguageEngine>(); List <string> treemock = new List <string> { "Hello", "You there", "Let's go there" }; Leng.KMPComparison = true; int expectedbest = Leng.BestDecision("You there", treemock); // Debug.Log(expectedbest); Assert.AreEqual(expectedbest, 1); }
// This tests the language engine Best Decision should return -1 given that there // is no match using word Comparison. public void LanguageEngineBestDecisionPassesGivenNoMatchwordcomp() { LangE = new GameObject(); LangE.AddComponent <LanguageEngine>(); Leng = LangE.GetComponent <LanguageEngine>(); List <string> treemock = new List <string> { "Hello", "You then", "Let's go then" }; Leng.wordComparison = true; Leng.KMPComparison = false; Assert.That(() => Leng.BestDecision("Friday", treemock), Throws.Exception); }
// This tests the language engine BestDecision method will return the correct index given // an edge case when using the KMP Comparison. public void LanguageEngineBestDecisionPassesGivenPartialEdgeCase1MatchKMPcomp() { LangE = new GameObject(); LangE.AddComponent <LanguageEngine>(); Leng = LangE.GetComponent <LanguageEngine>(); List <string> treemock = new List <string> { "Hello I am not feeling so well", "Hello I am feeling well today", "Hello I am not felling well today" }; Leng.KMPComparison = true; Leng.wordComparison = false; int expectedbest = Leng.BestDecision("Hello I am not well", treemock); // Debug.Log(expectedbest); Assert.AreEqual(0, expectedbest); }
// This tests the language engine BestDecision method will return the correct index given // a partiallly matching edge case option when using the KMP Comparison. // public void LanguageEngineBestDecisionPassesGivenPartialEdgeCase2MatchKMPcomp() { LangE = new GameObject(); LangE.AddComponent <LanguageEngine>(); Leng = LangE.GetComponent <LanguageEngine>(); List <string> treemock = new List <string> { "Hello Doctor I might have an issue here , my hand is broken", "my hand is in pain", "I think my hand is not broken" }; Leng.KMPComparison = true; Leng.wordComparison = false; int expectedbest = Leng.BestDecision("I might have broken my hand", treemock); // Debug.Log(expectedbest); Assert.AreEqual(expectedbest, 0); }
// This tests the language engine BestDecision method will return the correct index given // a matching second option when using the KMP Comparison. public void LanguageEngineBestDecisionPassesGivenFirstMatchKMPcomp() { LangE = new GameObject(); LangE.AddComponent <LanguageEngine>(); Leng = LangE.GetComponent <LanguageEngine>(); List <string> treemock = new List <string> { "Hello", "You there", "Let's go there" }; // Allows KMP algorithm for comparison Leng.KMPComparison = true; // Ensures only KMP algorithm is useds Leng.wordComparison = false; int expectedbest = Leng.BestDecision("Hello", treemock); // Debug.Log(expectedbest); Assert.AreEqual(expectedbest, 0); }
// This tests the language engine Best Decision should return -1 given that there // is no match using KMP Comparison. public void LanguageEngineBestDecisionPassesGivenNoMatchKMPcomp() { LangE = new GameObject(); LangE.AddComponent <LanguageEngine>(); Leng = LangE.GetComponent <LanguageEngine>(); List <string> treemock = new List <string> { "Hello", "You then", "Let's go then" }; Leng.wordComparison = false; Leng.KMPComparison = true; // Debug.Log(expectedbest); //Assert.AreEqual(expectedbest, -1); Assert.Throws <NoBestDecision>(() => { int expectedbest = Leng.BestDecision("Friday", treemock); }); }
// This tests the language engine BestDecisionMethod will return the correct index given // a matching first option when using word Comparison. public void LanguageEngineBestDecisionPassesGivenFirstMatchwordcomp() { LangE = new GameObject(); LangE.AddComponent <LanguageEngine>(); Leng = LangE.GetComponent <LanguageEngine>(); List <string> treemock = new List <string> { "Hello", "You there", "Let's go there" }; // Sets the word comparison to true to initiate wordComparison method Leng.wordComparison = true; // Ensures KMP does not interfere Leng.KMPComparison = false; int expectedbest = Leng.BestDecision("Hello", treemock); // Debug.Log(expectedbest); Assert.AreEqual(expectedbest, 0); // Use the Assert class to test conditions }