public void TestGetContent() { const string expectedContent = "<DISRules>" + "<rule name=\"Find the\" level=\"High\">" + "<results>" + "<result match=\"the\" context=\"Paragraph\" count=\"3\" />" + // "<result match=\"the\" context=\"Paragraph\" count=\"1\" />" + // "<result match=\"The\" context=\"Paragraph\" count=\"2\" />" + "</results>" + "</rule>" + "<rule name=\"Find that will\" level=\"Medium\">" + "<results>" + "<result match=\"that will\" context=\"Paragraph\" count=\"2\" />" + "</results>" + "</rule>" + "</DISRules>"; string testFilename = m_testPath + "TestContentAnalysisVisitor.txt"; DocumentReader documentReader = DocumentReaderFactory.Create(testFilename); WsScanRules rules = new WsScanRules(); rules.Add(new WsScanRule("Rule one", "Find the", "the", RuleLevels.High)); rules.Add(new WsScanRule("Rule two", "Find that will", "that will", RuleLevels.Medium)); ContentAnalysisVisitor contentAnalysisVisitor = new ContentAnalysisVisitor(rules); documentReader.Read(contentAnalysisVisitor); Assert.AreEqual(expectedContent, contentAnalysisVisitor.GetContent()); }
internal WsDocumentScanner(string filename, WsScanRules rules) { if(null == rules) return; m_contentAnalysisVisitor = new ContentAnalysisVisitor(rules); m_filename = filename; }
public void TestResults() { string testFilename = m_testPath + "TestContentAnalysisVisitor.txt"; DocumentReader documentReader = DocumentReaderFactory.Create(testFilename); WsScanRules rules = new WsScanRules(); rules.Add(new WsScanRule("Find the", "FindTheIndex", "the", RuleLevels.High)); rules.Add(new WsScanRule("Find that will", "FindThatIndex", "that will", RuleLevels.High)); ContentAnalysisVisitor contentAnalysisVisitor = new ContentAnalysisVisitor(rules); documentReader.Read(contentAnalysisVisitor); Assert.AreEqual(5, contentAnalysisVisitor.Results.TotalMatchCount); Assert.AreEqual(3, contentAnalysisVisitor.Results.GetMatches(RangeTypes.Paragraph, "FindTheIndex").TotalMatchCount); Assert.AreEqual(2, contentAnalysisVisitor.Results.GetMatches(RangeTypes.Paragraph, "FindThatIndex").TotalMatchCount); }
private void AddContentAnalysisObserver(NotifierVisitor notifierVisitor) { if (!Workshare.Interop.Options.OptionApi.GetBool("EnableContentDiscovery")) return; PolicyLoader policyLoader = new PolicyLoader(); WsScanRules scanRules = policyLoader.LoadScanRulesFromPolicy(); m_contentAnalysisVisitor = new ContentAnalysisVisitor(scanRules); notifierVisitor.Add(m_contentAnalysisVisitor); }
public void TestTrackChangesThatSpan() { const string expectedContent = "<DISRules>" + "<rule name=\"Find track change\" level=\"High\">" + "<results>" + // "<result match=\"Track change text\" context=\"TrackChange\" count=\"1\" />" + "<result match=\"track change text\" context=\"TrackChange\" count=\"1\" />" + "</results>" + "</rule>" + "</DISRules>"; string testFilename = m_testPath + "TrackChangesThatSpan.doc"; DocumentReader documentReader = DocumentReaderFactory.Create(testFilename); WsScanRules rules = new WsScanRules(); rules.Add(new WsScanRule("Test rule", "Find track change", "Track change text", RuleLevels.High)); ContentAnalysisVisitor contentAnalysisVisitor = new ContentAnalysisVisitor(rules); documentReader.Read(contentAnalysisVisitor); Assert.AreEqual(expectedContent, contentAnalysisVisitor.GetContent()); }