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_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 NormalizeFileData_Hebrew() { using (var ctrl = new CharContextCtrl()) { ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems, null, null, null, null); // First string is the normalized order that ICU produces. // Second string is the normalized order that .Net produces. var icuStyleNormalizationOrder = "\u05E9\u05c1\u05b4\u0596"; var dotnetStyleNormalizationOrder = "\u05E9\u05b4\u05c1\u0596"; ReflectionHelper.SetField(ctrl, "m_fileData", new[] { icuStyleNormalizationOrder, dotnetStyleNormalizationOrder }); // SUT ReflectionHelper.CallMethod(ctrl, "NormalizeFileData"); // Verify var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData"); Assert.That(results.Length, Is.EqualTo(2)); Assert.That(results[0], Is.EqualTo(icuStyleNormalizationOrder), GetMessage("Expect ICU-style normalization (from ICU order)", icuStyleNormalizationOrder, results[0])); Assert.That(results[1], Is.EqualTo(icuStyleNormalizationOrder), GetMessage("Expect ICU-style normalization (from .NET order)", icuStyleNormalizationOrder, results[1])); } }
public void NormalizeFileData_EnsureNFD() { CharContextCtrl ctrl = new CharContextCtrl(); // First string is the normalized order that ICU produces. // Second string is the normalized order that .Net produces. ReflectionHelper.SetField(ctrl, "m_fileData", new string[] { "\u2074" }); ReflectionHelper.SetProperty(ctrl, "Cache", Cache); ReflectionHelper.CallMethod(ctrl, "NormalizeFileData"); string[] results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData"); Assert.AreEqual(1, results.Length); Assert.AreEqual("\u2074", results[0], "Expect ICU-style normalization"); }
public void NormalizeFileData_EnsureNFD() { using (var ctrl = new CharContextCtrl()) { ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems, null, null, null, null); // First string is the normalized order that ICU produces. // Second string is the normalized order that .Net produces. ReflectionHelper.SetField(ctrl, "m_fileData", new[] { "\u2074" }); ReflectionHelper.CallMethod(ctrl, "NormalizeFileData"); var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData"); Assert.AreEqual(1, results.Length); Assert.AreEqual("\u2074", results[0], "Expect ICU-style normalization"); } }
public void NormalizeFileData_EnsureNFD() { using (var ctrl = new CharContextCtrl()) { ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems, null, null, null, null); ReflectionHelper.SetField(ctrl, "m_fileData", new[] { "\u2074" }); // SUT ReflectionHelper.CallMethod(ctrl, "NormalizeFileData"); // Verify var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData"); Assert.That(results.Length, Is.EqualTo(1)); Assert.That(results[0], Is.EqualTo("\u2074"), "Expect ICU-style normalization"); } }
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); } }
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() { 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); } }