public void GetTokenSubstrings_ValidatorThatRemovesSomeResults() { CharContextCtrl ctrl = new CharContextCtrl(); ctrl.Cache = Cache; ctrl.ListValidator = RemoveFirstAndLastSubString; List <ITextToken> tokens = new List <ITextToken>(); ITextToken token = new ScrCheckingToken(); ReflectionHelper.SetField(token, "m_sText", "Mom. Dad! Brother(Sister)"); tokens.Add(token); DummyScrInventory inventory = new DummyScrInventory(); inventory.m_references = new List <TextTokenSubstring>(); inventory.m_references.Add(new TextTokenSubstring(token, 3, 2)); inventory.m_references.Add(new TextTokenSubstring(token, 8, 2)); inventory.m_references.Add(new TextTokenSubstring(token, 17, 1)); inventory.m_references.Add(new TextTokenSubstring(token, 24, 1)); List <TextTokenSubstring> validatedList = (List <TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings", inventory, tokens); Assert.AreEqual(2, validatedList.Count); Assert.AreEqual("! ", validatedList[0].Text); Assert.AreEqual("(", validatedList[1].Text); }
public void GetTokenSubstrings_ValidatorThatRemovesSomeResults() { using (var ctrl = new CharContextCtrl()) { ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems, null, null, null, null); ctrl.ListValidator = RemoveFirstAndLastSubString; var tokens = new List <ITextToken>(); ITextToken token = new ScrCheckingToken(); ReflectionHelper.SetField(token, "m_sText", "Mom. Dad! Brother(Sister)"); tokens.Add(token); var inventory = new DummyScrInventory { m_references = new List <TextTokenSubstring> { new TextTokenSubstring(token, 3, 2), new TextTokenSubstring(token, 8, 2), new TextTokenSubstring(token, 17, 1), new TextTokenSubstring(token, 24, 1) } }; var validatedList = (List <TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings", inventory, tokens); Assert.AreEqual(2, validatedList.Count); Assert.AreEqual("! ", validatedList[0].Text); Assert.AreEqual("(", validatedList[1].Text); } }
public void GetTokenSubstrings_NoValidator() { CharContextCtrl ctrl = new CharContextCtrl(); ctrl.Cache = Cache; List <ITextToken> tokens = new List <ITextToken>(); ITextToken token = new ScrCheckingToken(); ReflectionHelper.SetField(token, "m_sText", "Mom. Dad!"); tokens.Add(token); DummyScrInventory inventory = new DummyScrInventory(); inventory.m_references = new List <TextTokenSubstring>(); inventory.m_references.Add(new TextTokenSubstring(token, 3, 2)); List <TextTokenSubstring> validatedList = (List <TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings", inventory, tokens); Assert.AreEqual(1, validatedList.Count); Assert.AreEqual(". ", validatedList[0].Text); }
public void GetTokenSubstrings_NoValidator() { using (var ctrl = new CharContextCtrl()) { ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems, null, null, null, null); var tokens = new List <ITextToken>(); ITextToken token = new ScrCheckingToken(); ReflectionHelper.SetField(token, "m_sText", "Mom. Dad!"); tokens.Add(token); var inventory = new DummyScrInventory { m_references = new List <TextTokenSubstring> { new TextTokenSubstring(token, 3, 2) } }; var validatedList = (List <TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings", inventory, tokens); Assert.AreEqual(1, validatedList.Count); Assert.AreEqual(". ", validatedList[0].Text); } }