void Test(string[] result, string text, string desiredKey) { m_source.Text = text; MixedCapitalizationCheck check = new MixedCapitalizationCheck(m_source); List <TextTokenSubstring> tts = check.GetReferences(m_source.TextTokens(), desiredKey); Assert.AreEqual(result.GetUpperBound(0) + 1, tts.Count, "A different number of results was returned than what was expected."); for (int i = 0; i <= result.GetUpperBound(0); ++i) { Assert.AreEqual(result[i], tts[i].InventoryText, "Result number: " + i.ToString()); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tests that processing the specified text using the GetReferences method produces the /// expected punctuation patterns. /// </summary> /// <param name="expectedPunctPatterns">The expected punct patterns.</param> /// <param name="expectedOffsets">The expected offsets.</param> /// <param name="text">A string marked up with SF codes representing a text to be /// processed.</param> /// ------------------------------------------------------------------------------------ void TestGetReferences(string[] expectedPunctPatterns, int[] expectedOffsets, string text) { Assert.AreEqual(expectedPunctPatterns.Length, expectedOffsets.Length, "Poorly defined expected test results."); m_dataSource.Text = text; PunctuationCheck check = new PunctuationCheck(m_dataSource); List <TextTokenSubstring> tts = check.GetReferences(m_dataSource.TextTokens(), String.Empty); Assert.AreEqual(expectedPunctPatterns.Length, tts.Count, "Unexpected number of punctuation patterns."); for (int i = 0; i < expectedPunctPatterns.Length; i++) { Assert.AreEqual(expectedPunctPatterns[i], tts[i].InventoryText, "Result number: " + i); Assert.AreEqual(expectedOffsets[i], tts[i].Offset, "Result number: " + i); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ void Test(string[,] result, string text) { m_dataSource.Text = text; List <TextTokenSubstring> tts = CheckInventory.GetReferences(m_dataSource.TextTokens(), string.Empty); Assert.AreEqual(result.GetUpperBound(0) + 1, tts.Count, "A different number of results was returned than what was expected."); for (int i = 0; i <= result.GetUpperBound(0); ++i) { Assert.AreEqual(result[i, 0], tts[i].InventoryText, "InventoryText number: " + i); Assert.AreEqual(result[i, 1], tts[i].Message, "Message number: " + i); } }
void Test(string[] result, string text) { source.Text = text; source.SetParameterValue("StylesInfo", stylesInfo); source.SetParameterValue("SentenceFinalPunctuation", ".!?"); CapitalizationCheck check = new CapitalizationCheck(source); List <TextTokenSubstring> tts = check.GetReferences(source.TextTokens()); Assert.AreEqual(result.Length, tts.Count, "A different number of results was returned from what was expected."); for (int i = 0; i < result.Length; i++) { Assert.AreEqual(result[i], tts[i].InventoryText, "Result number: " + i); } }