public void TestDiscoverRealCommentsWithLookupTable() { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); pca.AddAuthor(0, "Mena Shervill", 1); pca.AddAuthor(1, "bobh", 2); using (Stream from = File.Open(TESTFILE_DIR + "Ppt_comment1.xml", FileMode.Open)) { StateMachineBasedXmlFilter smbxf = new StateMachineBasedXmlFilter(new CommonNamespaces(OpenXmlFormat.Transitional)); smbxf.ConnectToInputStream(from); smbxf.AddNodesToTriggerList(PptxMetadataDefinitions.SlideComment(pca.AuthorByIDLookupDict)); DocumentText dt = smbxf.DocumentText; smbxf.Execute(); Assert.AreEqual(1, dt.GetTextTypes(ContentType.Comment).Count, "expected to get a comment text type created"); IAbstractTextType ttContent = dt.GetTextTypes(ContentType.Comment)[0]; Assert.IsNotNull(ttContent, "Missing Content Text Type"); Assert.AreEqual(3, ttContent.GetChildCount(), "we expected to get 3 items of comment text"); Assert.AreEqual("hjrehjkwr", ttContent.GetChild(0).GetInfo("Content")[0].value); Assert.AreEqual("Another comment", ttContent.GetChild(1).GetInfo("Content")[0].value); Assert.AreEqual("For use as no doubt", ttContent.GetChild(2).GetInfo("Content")[0].value); Assert.AreEqual("Mena Shervill", ttContent.GetChild(0).GetInfo("Author")[0].value); Assert.AreEqual("bobh", ttContent.GetChild(1).GetInfo("Author")[0].value); Assert.AreEqual("bobh", ttContent.GetChild(2).GetInfo("Author")[0].value); } }
public void TestAddAuthor() { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); pca.AddAuthor(0, "Author 1", 4); Assert.AreEqual(1, pca.NumberOfKnownAuthors); Assert.AreEqual("Author 1", pca.GetAuthorNameForIdx(0)); Assert.AreEqual(4, pca.GetMaxCommentIndexUsedForAuthorIdx(0)); pca.AddAuthor(1, "Author 2", 1); Assert.AreEqual(2, pca.NumberOfKnownAuthors); Assert.AreEqual("Author 2", pca.GetAuthorNameForIdx(1)); Assert.AreEqual(1, pca.GetMaxCommentIndexUsedForAuthorIdx(1)); Assert.AreEqual("Author 1", pca.GetAuthorNameForIdx(0)); Assert.AreEqual(4, pca.GetMaxCommentIndexUsedForAuthorIdx(0)); }
public void TestAddAuthorsInRandomOrder() { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); pca.AddAuthor(0, "Author A", 4); pca.AddAuthor(5, "Author B", 1); pca.AddAuthor(4, "Author C", 1); Assert.AreEqual(3, pca.NumberOfKnownAuthors); Assert.AreEqual("Author A", pca.GetAuthorNameForIdx(0)); Assert.AreEqual("Author C", pca.GetAuthorNameForIdx(4)); Assert.AreEqual("Author B", pca.GetAuthorNameForIdx(5)); int iMissedThrows = 0; try { pca.GetAuthorNameForIdx(-1); ++iMissedThrows; } catch { } try { pca.GetAuthorNameForIdx(1); ++iMissedThrows; } catch { } try { pca.GetAuthorNameForIdx(2); ++iMissedThrows; } catch { } try { pca.GetAuthorNameForIdx(3); ++iMissedThrows; } catch { } Assert.AreEqual(0, iMissedThrows,"Not all exceptional cases threw"); }
public void TestResettingKnownAuthorIsOK() { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); pca.AddAuthor(2, "Same Author", 4); Assert.AreEqual(4, pca.GetMaxCommentIndexUsedForAuthorIdx(2)); pca.AddAuthor(2, "Same Author", 1); Assert.AreEqual(4, pca.GetMaxCommentIndexUsedForAuthorIdx(2)); pca.AddAuthor(2, "Same Author", 7); Assert.AreEqual(7, pca.GetMaxCommentIndexUsedForAuthorIdx(2)); }
public void TestConstruction() { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); Assert.AreEqual(0, pca.NumberOfKnownAuthors); }
public void TestAuthorByIDLookupDict() { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); pca.AddAuthor(0, "Author A", 4); pca.AddAuthor(5, "Author B", 1); pca.AddAuthor(4, "Author C", 1); Dictionary<string, string> abild = pca.AuthorByIDLookupDict; Assert.AreEqual(3, abild.Count, "Should just have the 3 know nauthors"); Assert.AreEqual("Author A", abild["0"]); Assert.AreEqual("Author C", abild["4"]); Assert.AreEqual("Author B", abild["5"]); }
public void TestLoadFromStream() { using (Stream from = File.Open(TESTFILE_DIR + "Ppt_commentAuthors.xml", FileMode.Open)) { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); pca.ConnectToInputStream(from); pca.Execute(); Assert.AreEqual(2, pca.NumberOfKnownAuthors); Assert.AreEqual("Mena Shervill", pca.GetAuthorNameForIdx(0)); Assert.AreEqual(1, pca.GetMaxCommentIndexUsedForAuthorIdx(0)); Assert.AreEqual("bobh", pca.GetAuthorNameForIdx(1)); Assert.AreEqual(2, pca.GetMaxCommentIndexUsedForAuthorIdx(1)); } }
public void TestReuseAuthorFails() { PptxCommentAuthors pca = new PptxCommentAuthors(new DocumentText(), new CommonNamespaces(OpenXmlFormat.Transitional)); pca.AddAuthor(1, "Author First", 4); pca.AddAuthor(1, "Author Different", 4); }