Esempio n. 1
0
        public void MergeDocumentsFile()
        {
            RtfMerger merger = new RtfMerger("..\\..\\testdocs\\merge-template.rtf");

            merger.AddPlaceHolder("$doc1$", "..\\..\\testdocs\\merge-doc1.rtf");
            merger.AddPlaceHolder("$doc2$", "..\\..\\testdocs\\merge-doc2.rtf");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            merger.AddPlaceHolder("$doc3$", "..\\..\\testdocs\\merge-doc2.rtf");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(3));

            merger.RemovePlaceHolder("$doc3$");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            RtfTree tree = merger.Merge();

            tree.SaveRtf("..\\..\\testdocs\\merge-result-1.rtf");

            StreamReader sr = null;

            sr = new StreamReader("..\\..\\testdocs\\merge-result-1.rtf");
            string rtf1 = sr.ReadToEnd();

            sr.Close();

            sr = new StreamReader("..\\..\\testdocs\\rtf3.txt");
            string rtf3 = sr.ReadToEnd();

            sr.Close();

            Assert.That(rtf1, Is.EqualTo(rtf3));
        }
Esempio n. 2
0
        public void MergeDocumentsFile()
        {
            RtfMerger merger = new RtfMerger("..\\..\\testdocs\\merge-template.rtf");
            merger.AddPlaceHolder("$doc1$", "..\\..\\testdocs\\merge-doc1.rtf");
            merger.AddPlaceHolder("$doc2$", "..\\..\\testdocs\\merge-doc2.rtf");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            merger.AddPlaceHolder("$doc3$", "..\\..\\testdocs\\merge-doc2.rtf");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(3));

            merger.RemovePlaceHolder("$doc3$");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            RtfTree tree = merger.Merge();
            tree.SaveRtf("..\\..\\testdocs\\merge-result-1.rtf");

            StreamReader sr = null;
            sr = new StreamReader("..\\..\\testdocs\\merge-result-1.rtf");
            string rtf1 = sr.ReadToEnd();
            sr.Close();

            sr = new StreamReader("..\\..\\testdocs\\rtf3.txt");
            string rtf3 = sr.ReadToEnd();
            sr.Close();

            Assert.That(rtf1, Is.EqualTo(rtf3));
        }
Esempio n. 3
0
        public void MergeDocumentsInMemory()
        {
            RtfMerger merger = new RtfMerger();

            RtfTree tree = new RtfTree();

            tree.LoadRtfFile("..\\..\\testdocs\\merge-template.rtf");

            merger.Template = tree;

            RtfTree ph1 = new RtfTree();

            ph1.LoadRtfFile("..\\..\\testdocs\\merge-doc1.rtf");

            RtfTree ph2 = new RtfTree();

            ph2.LoadRtfFile("..\\..\\testdocs\\merge-doc2.rtf");

            merger.AddPlaceHolder("$doc1$", ph1);
            merger.AddPlaceHolder("$doc2$", ph2);

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            RtfTree ph3 = new RtfTree();

            ph3.LoadRtfFile("..\\..\\testdocs\\merge-doc2.rtf");

            merger.AddPlaceHolder("$doc3$", ph3);

            Assert.That(merger.Placeholders.Count, Is.EqualTo(3));

            merger.RemovePlaceHolder("$doc3$");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            RtfTree resTree = merger.Merge();

            resTree.SaveRtf("..\\..\\testdocs\\merge-result-2.rtf");

            StreamReader sr = null;

            sr = new StreamReader("..\\..\\testdocs\\merge-result-2.rtf");
            string rtf1 = sr.ReadToEnd();

            sr.Close();

            sr = new StreamReader("..\\..\\testdocs\\rtf3.txt");
            string rtf3 = sr.ReadToEnd();

            sr.Close();

            Assert.That(rtf1, Is.EqualTo(rtf3));
        }
Esempio n. 4
0
        public void MergeDocuments()
        {
            RtfMerger merger = new RtfMerger("..\\..\\testdocs\\merge-template.rtf", "..\\..\\testdocs\\merge-result.rtf", true);
            merger.AddPlaceHolder("$doc1$", "..\\..\\testdocs\\merge-doc1.rtf");
            merger.AddPlaceHolder("$doc2$", "..\\..\\testdocs\\merge-doc2.rtf");

            merger.AddPlaceHolder("$doc3$", "..\\..\\testdocs\\merge-doc2.rtf");
            merger.RemovePlaceHolder("$doc3$");

            merger.MergeRtfDoc();

            StreamReader sr = null;
            sr = new StreamReader("..\\..\\testdocs\\merge-result.rtf");
            string rtf1 = sr.ReadToEnd();
            sr.Close();

            sr = new StreamReader("..\\..\\testdocs\\rtf3.txt");
            string rtf3 = sr.ReadToEnd();
            sr.Close();

            Assert.That(rtf1, Is.EqualTo(rtf3));
        }
Esempio n. 5
0
        public void MergeDocumentsInMemory()
        {
            RtfMerger merger = new RtfMerger();

            RtfTree tree = new RtfTree();
            tree.LoadRtfFile("..\\..\\testdocs\\merge-template.rtf");

            merger.Template = tree;

            RtfTree ph1 = new RtfTree();
            ph1.LoadRtfFile("..\\..\\testdocs\\merge-doc1.rtf");

            RtfTree ph2 = new RtfTree();
            ph2.LoadRtfFile("..\\..\\testdocs\\merge-doc2.rtf");

            merger.AddPlaceHolder("$doc1$", ph1);
            merger.AddPlaceHolder("$doc2$", ph2);

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            RtfTree ph3 = new RtfTree();
            ph3.LoadRtfFile("..\\..\\testdocs\\merge-doc2.rtf");

            merger.AddPlaceHolder("$doc3$", ph3);

            Assert.That(merger.Placeholders.Count, Is.EqualTo(3));

            merger.RemovePlaceHolder("$doc3$");

            Assert.That(merger.Placeholders.Count, Is.EqualTo(2));

            RtfTree resTree = merger.Merge();
            resTree.SaveRtf("..\\..\\testdocs\\merge-result-2.rtf");

            StreamReader sr = null;
            sr = new StreamReader("..\\..\\testdocs\\merge-result-2.rtf");
            string rtf1 = sr.ReadToEnd();
            sr.Close();

            sr = new StreamReader("..\\..\\testdocs\\rtf3.txt");
            string rtf3 = sr.ReadToEnd();
            sr.Close();

            Assert.That(rtf1, Is.EqualTo(rtf3));
        }