public GetReferences ( IEnumerable |
||
tokens | IEnumerable |
|
desiredKey | string | e.g., _[_ or empty string to look for all patterns |
return | List |
public void GetReferences_AdvancedVerseNumBetweenNotes() { TestChecksDataSource dataSource = new TestChecksDataSource(); dataSource.SetParameterValue("PunctCheckLevel", "Advanced"); PunctuationCheck check = new PunctuationCheck(dataSource); dataSource.m_tokens.Add(new DummyTextToken("Wow", TextType.Verse, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("I am a note.", TextType.Note, true, true, "Note General Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("17", TextType.VerseNumber, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("\"I am a quote note!\"", TextType.Note, true, true, "Note General Paragraph")); List <TextTokenSubstring> tokens = check.GetReferences(dataSource.TextTokens(), string.Empty); Assert.AreEqual(3, tokens.Count); Assert.AreEqual("._", tokens[0].InventoryText); Assert.AreEqual(11, tokens[0].Offset); Assert.AreEqual("I am a note.", tokens[0].FirstToken.Text); Assert.AreEqual("_\"", tokens[1].InventoryText); Assert.AreEqual(0, tokens[1].Offset); Assert.AreEqual("\"I am a quote note!\"", tokens[1].FirstToken.Text); Assert.AreEqual("!\"_", tokens[2].InventoryText); Assert.AreEqual(18, tokens[2].Offset); Assert.AreEqual("\"I am a quote note!\"", tokens[2].FirstToken.Text); }
public void GetReferences_AdvancedDoubleStraightQuoteAfterVerseNum() { TestChecksDataSource dataSource = new TestChecksDataSource(); dataSource.SetParameterValue("PunctCheckLevel", "Advanced"); PunctuationCheck check = new PunctuationCheck(dataSource); dataSource.m_tokens.Add(new DummyTextToken("Wow.", TextType.Verse, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("17", TextType.VerseNumber, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("\"Word", TextType.Verse, false, false, "Paragraph")); List <TextTokenSubstring> tokens = check.GetReferences(dataSource.TextTokens(), string.Empty); Assert.AreEqual(2, tokens.Count); Assert.AreEqual("._", tokens[0].InventoryText); Assert.AreEqual(3, tokens[0].Offset); Assert.AreEqual("Wow.", tokens[0].FirstToken.Text); Assert.AreEqual("_\"", tokens[1].InventoryText); Assert.AreEqual(0, tokens[1].Offset); Assert.AreEqual("\"Word", tokens[1].FirstToken.Text); }
/// ------------------------------------------------------------------------------------ /// <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> /// 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); } }
public void GetReferences_AdvancedVerseNumBetweenNotes() { TestChecksDataSource dataSource = new TestChecksDataSource(); dataSource.SetParameterValue("PunctCheckLevel", "Advanced"); PunctuationCheck check = new PunctuationCheck(dataSource); dataSource.m_tokens.Add(new DummyTextToken("Wow", TextType.Verse, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("I am a note.", TextType.Note, true, true, "Note General Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("17", TextType.VerseNumber, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("\"I am a quote note!\"", TextType.Note, true, true, "Note General Paragraph")); List<TextTokenSubstring> tokens = check.GetReferences(dataSource.TextTokens(), string.Empty); Assert.AreEqual(3, tokens.Count); Assert.AreEqual("._", tokens[0].InventoryText); Assert.AreEqual(11, tokens[0].Offset); Assert.AreEqual("I am a note.", tokens[0].FirstToken.Text); Assert.AreEqual("_\"", tokens[1].InventoryText); Assert.AreEqual(0, tokens[1].Offset); Assert.AreEqual("\"I am a quote note!\"", tokens[1].FirstToken.Text); Assert.AreEqual("!\"_", tokens[2].InventoryText); Assert.AreEqual(18, tokens[2].Offset); Assert.AreEqual("\"I am a quote note!\"", tokens[2].FirstToken.Text); }
public void GetReferences_AdvancedDoubleStraightQuoteAfterVerseNum() { TestChecksDataSource dataSource = new TestChecksDataSource(); dataSource.SetParameterValue("PunctCheckLevel", "Advanced"); PunctuationCheck check = new PunctuationCheck(dataSource); dataSource.m_tokens.Add(new DummyTextToken("Wow.", TextType.Verse, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("17", TextType.VerseNumber, true, false, "Paragraph")); dataSource.m_tokens.Add(new DummyTextToken("\"Word", TextType.Verse, false, false, "Paragraph")); List<TextTokenSubstring> tokens = check.GetReferences(dataSource.TextTokens(), string.Empty); Assert.AreEqual(2, tokens.Count); Assert.AreEqual("._", tokens[0].InventoryText); Assert.AreEqual(3, tokens[0].Offset); Assert.AreEqual("Wow.", tokens[0].FirstToken.Text); Assert.AreEqual("_\"", tokens[1].InventoryText); Assert.AreEqual(0, tokens[1].Offset); Assert.AreEqual("\"Word", tokens[1].FirstToken.Text); }