public void TestReadWhiteText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "redacted.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.WhiteText).Count, 0, "No white text type found"); IAbstractTextType ttWhite = dt.GetTextTypes(ContentType.WhiteText)[0]; Assert.AreEqual(1, ttWhite.GetChildCount(), "expected to only have one piece of white text"); Assert.AreEqual("This text white", ttWhite.GetChild(0).GetInfo("Content")[0].value); Assert.Greater(dt.GetTextTypes(ContentType.RedactedText).Count, 0, "No redacted text type found"); IAbstractTextType ttRed = dt.GetTextTypes(ContentType.RedactedText)[0]; //Assert.AreEqual(12, ttRed.GetChildCount(), "expected to have twelve pieces of redacted text"); StringBuilder bld = new StringBuilder(); for (int i = 0; i < ttRed.GetChildCount(); i++) { bld.Append(ttRed.GetChild(i).GetInfo("Content")[0].value); } Assert.AreEqual("this auto highlighted blackthis black highlighted blackThis para on a black highlight.This Text is white. This Text is Red. This text is green.this is redThis text is blackthis text is black", bld.ToString(), "wrong text picked up as redacted"); //Assert.AreEqual("This para on a black highlight.This Text is White. This Text is Red. This Text is green.", ttRed.GetChild(0).GetInfo("Content")[0].value); //Assert.AreEqual("this is red", ttRed.GetChild(1).GetInfo("Content")[0].value); //Assert.AreEqual("This text is black", ttRed.GetChild(2).GetInfo("Content")[0].value); //Assert.AreEqual(", and this text is black.", ttRed.GetChild(3).GetInfo("Content")[0].value); } }
public void TestRead() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes().Count, 6, "expected at least 6 text types"); Assert.Greater(dt.GetTextTypes(ContentType.Field).Count, 0); Assert.Greater(dt.GetTextTypes(ContentType.HiddenText).Count, 0); Assert.Greater(dt.GetTextTypes(ContentType.SmartTag).Count, 0); Assert.Greater(dt.GetTextTypes(ContentType.SmallText).Count, 0); Assert.Greater(dt.GetTextTypes(ContentType.TrackChange).Count, 0); } }
public void TestReadDocProps() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.BuiltInProperty).Count, 0, "No built inproperty type found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.BuiltInProperty)[0]; CheckNode(ttProps, "Template", "Normal.dotm"); CheckNode(ttProps, "Company", "workshare"); CheckNode(ttProps, "Title", "DAVE METADATA TEST DOCUMENT VERSION 1 CREATED IN WORD 2003"); CheckNode(ttProps, "Author", "qaadmin"); Assert.AreEqual(4, ttProps.GetChildCount(), "didn't get enough items"); } }
public void TestReadWhiteTextWithStyles() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "redactedWithStyles.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.WhiteText).Count, 0, "No white text type found"); IAbstractTextType ttWhite = dt.GetTextTypes(ContentType.WhiteText)[0]; Assert.AreEqual(1, ttWhite.GetChildCount(), "expected to only have one piece of white text"); Assert.AreEqual("This text in white text char style", ttWhite.GetChild(0).GetInfo("Content")[0].value); Assert.Greater(dt.GetTextTypes(ContentType.RedactedText).Count, 0, "No redacted text type found"); IAbstractTextType ttRed = dt.GetTextTypes(ContentType.RedactedText)[0]; Assert.AreEqual(1, ttRed.GetChildCount(), "expected to only have one piece of redacted text"); Assert.AreEqual("And now black fg", ttRed.GetChild(0).GetInfo("Content")[0].value); } }
public void TestDiscoverSimpleDiagramPartialWhiteTextNoFill() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Single Smart Art Text Partial No fill Text.docx")) { DocumentText dt = reader.Read(); TextType ttDiagramText = dt.GetTextTypes(ContentType.WhiteText)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(1, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("content", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{003D71BC-AAAA-4A07-900B-0B97444F09C3}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); ttDiagramText = dt.GetTextTypes(ContentType.Paragraph)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(1, ttDiagramText.GetChildCount()); node = ttDiagramText.GetChild(0); Assert.AreEqual("This is the content of this smart art", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); } }
public void TestDiscoverSimpleDiagramPartialWhiteText() {//disable this as we cannot fix this without breaking lots of other things at the moment using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Single Smart Art Text Partial White Text.docx")) { DocumentText dt = reader.Read(); } // TextType ttDiagramText = dt.GetTextTypes(ContentType.WhiteText)[0] as TextType; // Assert.IsNotNull(ttDiagramText); // Assert.AreEqual(1, ttDiagramText.GetChildCount()); // IAbstractTextNode node = ttDiagramText.GetChild(0); // Assert.AreEqual("content ", node.GetInfo("Content")[0].value, "wrong text reported"); // Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); // Assert.AreEqual("{003D71BC-AAAA-4A07-900B-0B97444F09C3}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); // ttDiagramText = dt.GetTextTypes(ContentType.Paragraph)[0] as TextType; // Assert.IsNotNull(ttDiagramText); // Assert.AreEqual(1, ttDiagramText.GetChildCount()); // node = ttDiagramText.GetChild(0); // Assert.AreEqual("This is the content of this smart art", node.GetInfo("Content")[0].value, "wrong text reported"); // Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); //} }
public void TestDiscoverNestedDiagramWhiteText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Nested Smart Art Text Colours.docx")) { DocumentText dt = reader.Read(); TextType ttDiagramText = dt.GetTextTypes(ContentType.WhiteText)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(1, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("This is white on a white background", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{ACE86D7C-78FB-4963-B821-2F5FF75E5F04}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); ttDiagramText = dt.GetTextTypes(ContentType.Paragraph)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(3, ttDiagramText.GetChildCount()); node = ttDiagramText.GetChild(0); Assert.AreEqual("This is not white", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{ABE52CEC-EB0A-4B90-B1E0-7EF207627444}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(1); Assert.AreEqual("This is white but not on a white background", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{3E59C3C3-8D9D-461D-843B-A7EEE18E0378}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(2); Assert.AreEqual("This is white on a white background", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{ACE86D7C-78FB-4963-B821-2F5FF75E5F04}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); } }
public void TestDiscoverNastyNestedDiagramWhiteText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Nasty Nested Smart Art.docx")) { DocumentText dt = reader.Read(); TextType ttDiagramText = dt.GetTextTypes(ContentType.WhiteText)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(3, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("Second", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{D77402D9-ECEF-467C-AF67-93DE6025A0D8}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(1); Assert.AreEqual("Second Second", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{AE00D978-0003-4C83-88CF-CFBBB8950F3A}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(2); Assert.AreEqual("Middle First", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{1C564F54-8B8C-4593-AF15-C79E46AF24C5}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); ttDiagramText = dt.GetTextTypes(ContentType.Paragraph)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(12, ttDiagramText.GetChildCount()); int index = 0; node = ttDiagramText.GetChild(index++); Assert.AreEqual("Here is some text before any shapes or stuff.", node.GetInfo("Content")[0].value, "wrong text reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("First", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{3582C0A5-B08A-4118-B613-44947BB9C9A3}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Inner First", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{40E9C0BD-5531-46DA-9418-B1814036DE27}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Second First", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{A68E6197-0704-48CF-A3FC-0CBF610B365D}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Second", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{D77402D9-ECEF-467C-AF67-93DE6025A0D8}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Inner Second", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{25711D54-A912-4951-9B44-B001B92929CA}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Second Second", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{AE00D978-0003-4C83-88CF-CFBBB8950F3A}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Third", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{51D433B4-7949-448D-9647-30B99DF3CBBB}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Inner Third", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{146B31C8-07F9-432A-B24B-42C84282B2BA}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Second Third", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{36A5A0E7-48CE-4615-9551-E37215F36EED}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Third Third", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{BE0A47CE-72C0-40E8-8E18-4E1C80B97035}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(index++); Assert.AreEqual("Middle First", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{1C564F54-8B8C-4593-AF15-C79E46AF24C5}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); } }
public void TestDiscoverDiagramSmallText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Small Text in Smart Art.docx")) { DocumentText dt = reader.Read(); TextType ttDiagramText = dt.GetTextTypes(ContentType.SmallText)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(4, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("Here and there", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{023F42EA-B44E-477E-BC68-14C78F8BC7BE}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(1); Assert.AreEqual("wide", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{D4C760D3-9B3D-41FD-AF88-CBDEF0DD4C80}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(2); Assert.AreEqual("In", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{6100147A-27A3-4EC6-8C14-CFDBD1669438}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(3); Assert.AreEqual("and", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{1B529BC4-0E0F-40EC-8F2D-D3D64DF9CB3C}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); } }
public void TestReadCustProps() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.CustomProperty).Count, 0, "No custom property type found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.CustomProperty)[0]; CheckNode(ttProps, "dave", "custom prop"); CheckNode(ttProps, "Date completed", "2006-05-04T00:00:00Z"); CheckNode(ttProps, "Document number", "1234"); CheckNode(ttProps, "Secure", "true"); Assert.Greater(ttProps.GetChildCount(), 0, "expected at least some custom properties"); Assert.AreEqual(4, ttProps.GetChildCount(), "expected 4 custom properties"); } }
public void TestReadComments() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.Comment).Count, 0, "No comment property type found"); IAbstractTextType ttComment = dt.GetTextTypes(ContentType.Comment)[0]; Assert.AreEqual(2, ttComment.GetChildCount(), "expected to find 2 comments"); IAbstractTextNode node = ttComment.GetChild(0); Assert.AreEqual("This is a second comment by me", node.GetInfo("Content")[0].value, "wrong comment text reported"); Assert.AreEqual("bobh", node.GetInfo("Author")[0].value, "wrong comment author reported"); Assert.AreEqual("1972-10-25T04:56:00Z", node.GetInfo("Date")[0].value, "wrong comment date reported"); Assert.AreEqual("b", node.GetInfo("Initials")[0].value, "wrong comment initials reported"); } }
public void TestDiscoverSimpleDiagramAsRedactedText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Single Smart Art Text Redacted.docx")) { DocumentText dt = reader.Read(); TextType ttDiagramText = dt.GetTextTypes(ContentType.RedactedText)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(1, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("This is the content of this smart art", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); } }
public void TestReadFooter() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.Footer).Count, 0, "No footer property type found"); IAbstractTextType ttFooter = dt.GetTextTypes(ContentType.Footer)[0]; Assert.AreEqual(1, ttFooter.GetChildCount(), "expected to find one footer"); IAbstractTextNode node = ttFooter.GetChild(0); string sFooterText = node.GetInfo("Content")[0].value; Assert.AreNotEqual(-1, sFooterText.IndexOf("WORD 2003"), "wrong footer text reported"); } }
public void TestReadHeader() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.Header).Count, 0, "No header property type found"); IAbstractTextType ttHeader = dt.GetTextTypes(ContentType.Header)[0]; Assert.AreEqual(1, ttHeader.GetChildCount(), "expected to find one header"); IAbstractTextNode node = ttHeader.GetChild(0); var expected = " TIME \\@ \"h:mm:ss am/pm\" 11:21:55 AM11:49:09 AM"; var result = node.GetInfo("Content")[0].value; Assert.True(String.Compare(expected, result) == 0); } }
public void TestReadEndnotes() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.Endnote).Count, 0, "No endnote property type found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.Endnote)[0]; Assert.AreEqual(1, ttProps.GetChildCount(), "expected to find one endnote"); IAbstractTextNode node = ttProps.GetChild(0); Assert.AreEqual(" This is an inserted endnote", node.GetInfo("Content")[0].value, "wrong endnote text reported"); } }
public void TestReadReviewers() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test003.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.Reviewer).Count, 0, "No workshare property type found"); IAbstractTextType ttRevs = dt.GetTextTypes(ContentType.Reviewer)[0]; Assert.AreEqual("robin", ttRevs.GetChild(0).GetInfo("Content")[0].value, "wrong content extracted from the text box"); Assert.AreEqual("qaadmin", ttRevs.GetChild(1).GetInfo("Content")[0].value, "wrong content extracted from the text box"); Assert.AreEqual("bobh", ttRevs.GetChild(2).GetInfo("Content")[0].value, "wrong content extracted from the text box"); Assert.AreEqual("lnpair", ttRevs.GetChild(3).GetInfo("Content")[0].value, "wrong content extracted from the text box"); Assert.AreEqual(4, ttRevs.GetChildCount(), "expected 4 reviewers"); } }
public void TestReadWorkshareProps() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test003.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.WorkshareProperty).Count, 0, "No workshare property type found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.WorkshareProperty)[0]; CheckNode(ttProps, "SFR_COMPUTER_NAME", "frog"); CheckNode(ttProps, "WS_RTS_TAG_EX", "cheesecake"); Assert.AreEqual(2, ttProps.GetChildCount(), "expected 2 workshare properties"); } }
public void TestDiscoverSimpleDiagramWhiteTextWithBorderIsNotDiscoveredAsWhiteText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Single Smart Art Text White Text with Border.docx")) { DocumentText dt = reader.Read(); List<IAbstractTextType> ttDiagramList = dt.GetTextTypes(ContentType.WhiteText); Assert.AreEqual(0, ttDiagramList.Count, "Shouldn't have found any white text"); TextType ttDiagramText = dt.GetTextTypes(ContentType.Paragraph)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(1, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("This is the content of this smart art", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); } }
public void TestDiscoverInkAnnotations_2() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Ink Annotations 4.docx")) { DocumentText dt = reader.Read(); TextType ttInks = dt.GetTextTypes(ContentType.InkAnnotation)[0] as TextType; Assert.IsNotNull(ttInks); Assert.AreEqual(2, ttInks.GetChildCount()); int i = 0; Assert.AreEqual("_x0000_i1025", ttInks.GetChild(i).GetInfo("ShapeId")[0].value); Assert.AreEqual("_x0000_i1026", ttInks.GetChild(++i).GetInfo("ShapeId")[0].value); } }
public void TestDiscoverSimpleDiagramRedactedTextWithBorderIsNotDiscoveredAsRedactedText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Single Smart Art Text Redacted with Border.docx")) { DocumentText dt = reader.Read(); List<IAbstractTextType> tText = dt.GetTextTypes(ContentType.RedactedText); Assert.AreEqual(0, tText.Count, "Didn't expect to find any redacted text"); } }
public void TestReadParagraphText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "paratext.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.Paragraph).Count, 0, "No paragraph type found"); IAbstractTextType ttPara = dt.GetTextTypes(ContentType.Paragraph)[0]; Assert.AreEqual(3, ttPara.GetChildCount(), "didn't get right number of items"); Assert.AreEqual("This is paragraph one", ttPara.GetChild(0).GetInfo("Content")[0].value, "wrong content extracted from the text box"); Assert.AreEqual("This is the second paragraph", ttPara.GetChild(1).GetInfo("Content")[0].value, "wrong content extracted from the text box"); Assert.AreEqual("And that’s all folks", ttPara.GetChild(2).GetInfo("Content")[0].value, "wrong content extracted from the text box"); } }
public void TestDiscoverMoreComplexDiagramAsRedactedText() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Redacted Smart Art.docx")) { DocumentText dt = reader.Read(); TextType ttDiagramText = dt.GetTextTypes(ContentType.RedactedText)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(4, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("Secondary Level Boss", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{945DC942-DC96-42C9-98C7-9CD326E28E92}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(1); Assert.AreEqual("at the ", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{FC49DE13-1B95-4789-8162-F4F86D26654F}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(2); Assert.AreEqual("Level", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{0E882CA2-F24B-49C5-9D7F-343EB3FD29E9}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(3); Assert.AreEqual("Middle Level", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{CBF2ACC4-CF8F-4333-86F0-254678EC1995}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); } }
public void TestReadTextBox() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test003.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.TextBox).Count, 0, "No text box type found"); IAbstractTextType ttTextBox = dt.GetTextTypes(ContentType.TextBox)[0]; Assert.AreEqual(1, ttTextBox.GetChildCount(), "didn't get enough items"); IAbstractTextNode node = ttTextBox.GetChild(0); Assert.AreEqual("This is some text in a text box. We need to detect this.", node.GetInfo("Content")[0].value, "wrong content extracted from the text box"); } }
public void TestReadDocVars() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.Variable).Count, 0, "No document variable property type found"); IAbstractTextType ttVar = dt.GetTextTypes(ContentType.Variable)[0]; Assert.AreEqual(1, ttVar.GetChildCount(), "expected to find 1 document variable"); IAbstractTextNode node = ttVar.GetChild(0); Assert.AreEqual("1", node.GetInfo("variable")[0].value, "wrong variable info reported"); } }
public void TestReadDocStats() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test002.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.DocumentStatistic).Count, 0, "No doc statistics type found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.DocumentStatistic)[0]; CheckNode(ttProps, "LastAuthor", "lnpair"); CheckNode(ttProps, "RevisionNumber", "2"); CheckNode(ttProps, "CreatedTime", "2014-08-14T10:23:00Z"); CheckNode(ttProps, "LastSaveTime", "2014-08-14T10:23:00Z"); CheckNode(ttProps, "EditTime", "0"); Assert.AreEqual(5, ttProps.GetChildCount(), "didn't get enough items"); } }
public void TestDiscoverInkAnnotations_3() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Ink Annotations 5.docx")) { DocumentText dt = reader.Read(); TextType ttInks = dt.GetTextTypes(ContentType.InkAnnotation)[0] as TextType; Assert.IsNotNull(ttInks); Assert.AreEqual(3, ttInks.GetChildCount()); int i = 0; Assert.AreEqual(@"ink/ink1.xml", ttInks.GetChild(i).GetInfo("Source")[0].value); Assert.AreEqual(@"ink/ink3.xml", ttInks.GetChild(++i).GetInfo("Source")[0].value); Assert.AreEqual(@"ink/ink2.xml", ttInks.GetChild(++i).GetInfo("Source")[0].value); } }
public void TestDiscoverHyperlinksInTextBox() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Hyperlinks In Textbox.docx")) { DocumentText dt = reader.Read(); TextType ttCustProps = dt.GetTextTypes(ContentType.Hyperlink)[0] as TextType; Assert.IsNotNull(ttCustProps); Assert.AreEqual(6, ttCustProps.GetChildCount()); } }
public void TestReadTextBox() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "test003.docx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.TextBox).Count, 0, "No text box type found"); IAbstractTextType ttTextBox = dt.GetTextTypes(ContentType.TextBox)[0]; Assert.AreEqual(2, ttTextBox.GetChildCount()); Assert.AreEqual("This is some text in a text box. We need to detect this.", ttTextBox.GetChild(0).GetInfo("Content")[0].value); Assert.AreEqual("This is some text in a text box. We need to detect this.", ttTextBox.GetChild(1).GetInfo("Content")[0].value); } }
public void TestDiscoverTextInSimpleDiagram() { using (DocxDocumentReader reader = new DocxDocumentReader(TESTFILE_DIR + "Test Smart Art Text.docx")) { DocumentText dt = reader.Read(); TextType ttDiagramText = dt.GetTextTypes(ContentType.Paragraph)[0] as TextType; Assert.IsNotNull(ttDiagramText); Assert.AreEqual(5, ttDiagramText.GetChildCount()); IAbstractTextNode node = ttDiagramText.GetChild(0); Assert.AreEqual("First", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{C2FC0B84-3608-4CFF-A0C4-E5D6DBD4A625}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(1); Assert.AreEqual("Second", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{D9D50BED-AB4B-41EF-AFFB-E895787A69DE}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(2); Assert.AreEqual("Third", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{52EBCD87-1BF4-42EF-8BF0-1782A964EA93}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(3); Assert.AreEqual("Fourth", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{2700E780-5B7F-46A2-9D9B-2B174297D36F}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); node = ttDiagramText.GetChild(4); Assert.AreEqual("Fifth", node.GetInfo("Content")[0].value, "wrong text reported"); Assert.AreEqual("Diagram_Text", node.GetInfo("Type")[0].value, "wrong text type reported"); Assert.AreEqual("{56CFD1AB-B10B-4759-BF32-1443B3063F7E}", node.GetInfo("ModelId")[0].value, "wrong model Id reported"); } }