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 Check_PatternsWithSpaceSeparatedQuoteMarks() { PuncPatternsList puncPatterns = new PuncPatternsList(); PuncPattern pattern = new PuncPattern(); pattern.Pattern = ",_"; pattern.ContextPos = ContextPosition.WordFinal; pattern.Status = PuncPatternStatus.Valid; puncPatterns.Add(pattern); pattern = new PuncPattern(); pattern.Pattern = "_\u201C"; pattern.ContextPos = ContextPosition.WordInitial; pattern.Status = PuncPatternStatus.Valid; puncPatterns.Add(pattern); pattern = new PuncPattern(); pattern.Pattern = "_\u2018"; pattern.ContextPos = ContextPosition.WordInitial; pattern.Status = PuncPatternStatus.Valid; puncPatterns.Add(pattern); m_dataSource.SetParameterValue("PunctuationPatterns", puncPatterns.XmlString); m_dataSource.SetParameterValue("PunctCheckLevel", "Intermediate"); PunctuationCheck check = new PunctuationCheck(m_dataSource); m_dataSource.Text = "\\p Tom replied, \u201CBill said, \u2018Yes!\u2019\u202F\u201D"; check.Check(m_dataSource.TextTokens(), RecordError); Assert.AreEqual(1, m_errors.Count); CheckError(0, "Tom replied, \u201CBill said, \u2018Yes!\u2019\u202F\u201D", 29, "!\u2019\u202F\u201D", "Unspecified use of punctuation pattern"); }
public void Check_ValidPatternsAreNotReported() { PuncPatternsList puncPatterns = new PuncPatternsList(); PuncPattern pattern = new PuncPattern(); pattern.Pattern = "._"; pattern.ContextPos = ContextPosition.WordFinal; pattern.Status = PuncPatternStatus.Valid; puncPatterns.Add(pattern); pattern = new PuncPattern(); pattern.Pattern = ","; pattern.ContextPos = ContextPosition.WordBreaking; pattern.Status = PuncPatternStatus.Invalid; puncPatterns.Add(pattern); m_dataSource.SetParameterValue("PunctuationPatterns", puncPatterns.XmlString); m_dataSource.SetParameterValue("PunctCheckLevel", "Intermediate"); PunctuationCheck check = new PunctuationCheck(m_dataSource); m_dataSource.Text = "\\p This is nice. By nice,I mean really nice!"; check.Check(m_dataSource.TextTokens(), RecordError); Assert.AreEqual(2, m_errors.Count); CheckError(0, "This is nice. By nice,I mean really nice!", 21, ",", "Invalid punctuation pattern"); CheckError(1, "This is nice. By nice,I mean really nice!", 40, "!", "Unspecified use of punctuation pattern"); }
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); }
public void FixtureSetup() { QuotationMarksList qmarks = QuotationMarksList.NewList(); qmarks.QMarksList[0].Opening = "\u201C"; qmarks.QMarksList[0].Closing = "\u201D"; qmarks.QMarksList[1].Opening = "\u2018"; qmarks.QMarksList[1].Closing = "\u2019"; qmarks.EnsureLevelExists(5); m_dataSource.SetParameterValue("QuotationMarkInfo", qmarks.XmlString); m_dataSource.SetParameterValue("PunctWhitespaceChar", "_"); m_check = new PunctuationCheck(m_dataSource); }
public void Check_MultiCharPatterns() { m_dataSource.SetParameterValue("PunctuationPatterns", String.Empty); m_dataSource.SetParameterValue("PunctCheckLevel", "Intermediate"); PunctuationCheck check = new PunctuationCheck(m_dataSource); m_dataSource.Text = "\\p This _> is!?."; check.Check(m_dataSource.TextTokens(), RecordError); Assert.AreEqual(2, m_errors.Count); CheckError(0, "This _> is!?.", 5, "_>", "Unspecified use of punctuation pattern"); CheckError(1, "This _> is!?.", 10, "!?.", "Unspecified use of punctuation pattern"); }
/// ------------------------------------------------------------------------------------ /// <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 Check_ParaWithSingleQuotationMark() { PuncPatternsList puncPatterns = new PuncPatternsList(); PuncPattern pattern = new PuncPattern(); pattern.Pattern = "._"; pattern.ContextPos = ContextPosition.WordFinal; pattern.Status = PuncPatternStatus.Valid; puncPatterns.Add(pattern); m_dataSource.SetParameterValue("PunctuationPatterns", puncPatterns.XmlString); m_dataSource.SetParameterValue("PunctCheckLevel", "Intermediate"); PunctuationCheck check = new PunctuationCheck(m_dataSource); m_dataSource.Text = "\\p wow\u201D\\p \u2019"; check.Check(m_dataSource.TextTokens(), RecordError); Assert.AreEqual(2, m_errors.Count); CheckError(0, "wow\u201D", 3, "\u201D", "Unspecified use of punctuation pattern"); CheckError(1, "\u2019", 0, "\u2019", "Unspecified use of punctuation pattern"); }
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); }