public void TestTextLookupCount() { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\TestDocument1.doc"); string description = "Originally a test document used by one of FCS Lite's tests."; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] content = { "A4CC013A-BBE2-4a21-8651-F4511D689EDA" }; string[] context = { "Paragraph", "Header", "Footer", "Comment", "Footnote", "Endnote", "TrackChange", "TextBox", "Reviewer", "HiddenText", "SmallText", "WhiteText", "AttachedTemplate", "SmartTag", "Version", "AutoVersion", "Field", "Hyperlink", "RoutingSlip", "Variable", "HiddenSlide", "SpeakerNote" }; int textCount = analysis.TextLookupCount(testFile, content, context); Assert.AreEqual(6, textCount, "Expected value of textCount to be [5], but was [" + textCount + "]"); } }
public void TestTextLookupCountCorruptedWordDoc() { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\TestDocument1.doc"); string description = "Originally a test document used by one of FCS Lite's tests."; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] content = { "A4CC013A-BBE2-4a21-8651-F4511D689EDA" }; string[] context = { "Paragraph", "Header", "Footer", "Comment", "Footnote", "Endnote", "TrackChange", "TextBox", "Reviewer", "HiddenText", "SmallText", "WhiteText", "AttachedTemplate", "SmartTag", "Version", "AutoVersion", "Field", "Hyperlink", "RoutingSlip", "Variable", "HiddenSlide", "SpeakerNote" }; try { int textCount = analysis.TextLookupCount(testFile, content, context); Assert.Fail("Should have thrown an exception on reading corrupted WORD document"); } catch (Exception e) { string msg = e.Message; } } }
public void TestHtmlHTMLTextLookupCount() { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = m_testunicodehtmldoc; string description = "An HTML file"; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] content = { "testing" }; string[] context = { "Paragraph" }; int textCount = analysis.TextLookupCount(testFile, content, context); Assert.AreEqual(1, textCount, "Expected value of textCount to be [1], but was [" + textCount + "]"); // this removed until we can look at HtmlAgilityPack's use of codepages //string[] content2 = { "正規表現" }; //textCount = analysis.TextLookupCount(testFile, content2, context); //Assert.AreEqual(1, textCount, "Expected value of textCount to be [1], but was [" + textCount + "]"); } }
public void TestPerformance() { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\TestDocumentBig.doc"); string description = "Originally a test document used by one of FCS Lite's tests."; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string regEx = @"(The quick brown fox jumped over the lazy dog.){1}"; string[] content = { "A4CC013A-BBE2-4a21-8651-F4511D689EDA" }; string[] context = { "Paragraph", "HeaderOrFooter", "Comment", "Footnote", "Endnote", "TrackChange", "TextBox", "Reviewer", "HiddenText", "SmallText", "WhiteText", "AttachedTemplate", "SmartTag", "Version", "AutoVersion", "Field", "Hyperlink", "RoutingSlip", "Variable", "HiddenSlide", "SpeakerNote" }; int textCount = analysis.TextLookupCount(testFile, content, context); int regexCount = analysis.RegExLookupCount(testFile, regEx, context); } }
public void TestFallbackTextLookupCountBadType() { try { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\unrecognized_type.xyz"); string description = "A random chunk of binary rubbish"; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] content = { "text" }; string[] context = { "Paragraph" }; int textCount = analysis.TextLookupCount(testFile, content, context); } } catch(Exception) { Assert.Fail("Fallback should not cause an exception when analysing a corrupt document"); } }
public void TestFallbackTextLookupCount() { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\lotus-wordpro.lwp"); string description = "A lotus wordpro document"; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] content = { "text" }; string[] context = { "Paragraph" }; int textCount = analysis.TextLookupCount(testFile, content, context); Assert.AreEqual(69, textCount, "Expected value of textCount to be [69], but was [" + textCount + "]"); } }
public void TestPdfLookupCountOnCorruptedPdf() { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\test2corrupted.pdf"); string description = "A corrupted pdf document"; try { using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] content = { "point" }; string[] context = { "Paragraph" }; int textCount = analysis.TextLookupCount(testFile, content, context); Assert.Fail("Should have thrown an exception on reading corrupt document"); } } catch (Exception e) { string message = e.Message; } }
public void TestPdfTextLookupCountOverLineBreaks2() { Workshare.Policy.Condition.ContentAnalysis analysis = new Workshare.Policy.Condition.ContentAnalysis(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\testlookup_adobe.pdf"); string description = "Test pdf document"; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] content = { "This first paragraph extends over multiple" };// multiple lines" }; string[] context = { "Paragraph" }; int textCount = analysis.TextLookupCount(testFile, content, context); Assert.AreEqual(1, textCount, "Expected value of textCount to be [1], but was [" + textCount + "]"); } }