Index: xword/ContentFiltering/ContentFiltering.csproj =================================================================== --- xword/ContentFiltering/ContentFiltering.csproj (revision 21744) +++ xword/ContentFiltering/ContentFiltering.csproj (working copy) @@ -68,10 +68,12 @@ + + @@ -98,9 +100,11 @@ + + @@ -125,6 +129,11 @@ XWikiLib + + + PreserveNewest + + +Pre-DOM Filters Test Page + + + + + + + + + + +
+ +
+ +

Document Title

+ +
+ +

Heading 1

+ +

Some text content goes here. More and more text content goes +here. Perhaps we should put some bold +text, or underlined text or italics +text. What do you think about striked text? Now lets change the +font color. I hope you like bold underlined italic red +text. Or just some normal blue text?

+ +

bg001.bmp

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

ITEM

+
+

NEEDED

+
+

Books

+
+

1

+
+

Magazines

+
+

3

+
+

Notebooks

+
+

1

+
+

Paper pads

+
+

1

+
+

Pens

+
+

3

+
+

Pencils

+
+

2

+
+

Highlighter

+
+

2 colors

+
+

Scissors

+
+

1 pair

+
+ +

 

+ + + + + + + + + + + +
+

1

+
+

2

+
+

3

+
+

4

+
+

5

+
+ +

 

+ +

 

+ +

+ +

 

+ +

Thats it, folks!

+ +

 

+
+ + + Index: xword/ContentFiltering/Test/Office/Word/Cleaners/WebToLocalHTMLCleanerTest.cs =================================================================== --- xword/ContentFiltering/Test/Office/Word/Cleaners/WebToLocalHTMLCleanerTest.cs (revision 0) +++ xword/ContentFiltering/Test/Office/Word/Cleaners/WebToLocalHTMLCleanerTest.cs (revision 0) @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; +using System.Xml; +using ContentFiltering.Office.Word.Cleaners; +using System.IO; + +namespace ContentFiltering.Test.Office.Word.Cleaners +{ + /// + /// Test class for WebToLocalHTMLCleaner. + /// + [TestFixture] + public class WebToLocalHTMLCleanerTest + { + private string htmlContent; + private string htmlOpeningTag; + private XmlDocument xmlDoc; + + /// + /// Default constructor. + /// + public WebToLocalHTMLCleanerTest() + { + htmlContent = ""; + htmlOpeningTag = ""; + xmlDoc = new XmlDocument(); + } + + [TestFixtureSetUp] + public void TestSetup() + { + htmlContent = LoadTextFromFile(@"Test\Office\Word\Cleaners\TestsResources\PreDomFiltersTestPage.html"); + htmlOpeningTag = ""; + } + + // + /// Loads an HTML file from disk, cleans the content with WebToLocalHTMLCleaner and then it + /// tries to load the cleaned HTML into an XmlDocument. + /// + [Test] + public void TestCleaner() + { + bool noException = true; + try + { + htmlContent = new WebToLocalHTMLCleaner(htmlOpeningTag).Clean(htmlContent); + xmlDoc.LoadXml(htmlContent); + } + catch(Exception e) + { + Console.Error.WriteLine(e); + noException = false; + } + + Assert.IsTrue(noException); + } + + + private string LoadTextFromFile(string path) + { + string content = ""; + try + { + TextReader tr = new StreamReader(path); + content = tr.ReadToEnd(); + tr.Close(); + } + catch + { + } + return content; + } + } +}