示例#1
0
        public void SaveNewDocumentInODFWithNotSupportedExtension()
        {
            var fileName = string.Format("{0}\\{1}", FILE_PATH, "Test.odf");
            var document = TextDocument.Create(fileName, true);

            Assert.Throws <FileLoadException>(() => document.Save(DocumentType.ODFTextDocument));
        }
示例#2
0
        public void CreateExistingDocumentFromTemplate()
        {
            var templateLocation = string.Format("{0}\\{1}.{2}", TEMPLATE_PATH, TEMPLATE_NAME, TEMPLATE_EXTENSION);
            var filename         = string.Format("{0}\\{1}.{2}", DOCUMENT_PATH, DOCUMENT_NAME, DOCUMENT_EXTENSION);

            Assert.Throws <FileNotFoundException>(() => TextDocument.Create(Path.GetFullPath(filename), Path.GetFullPath(templateLocation), false));
        }
示例#3
0
        public EditTextDocumentTests(ShakespeareFixtures shakespeareFixtures)
        {
            _shakespeareFixtures = shakespeareFixtures;

            _document    = TextDocument.Create();
            _paragraphId = Guid.NewGuid().ToString();
        }
示例#4
0
        public void CreateNamedDocument()
        {
            TextDocument doc = TextDocument.Create("test.docx", true);

            Assert.NotNull(doc);
            if (doc != null)
            {
                Assert.Equal("test.docx", doc.Filename);
            }
        }
示例#5
0
        public void CreateDocumentFromTemplate()
        {
            var          templateLocation = string.Format("{0}\\{1}.{2}", TEMPLATE_PATH, TEMPLATE_NAME, TEMPLATE_EXTENSION);
            TextDocument doc = TextDocument.Create("test.docx", templateLocation, true);

            Assert.NotNull(doc);
            if (doc != null)
            {
                Assert.Equal("test.docx", doc.Filename);
            }
        }
示例#6
0
        public void CreateEmptyDocument()
        {
            TextDocument doc = TextDocument.Create();

            Assert.NotNull(doc);
            if (doc != null)
            {
                doc.Filename = "test.docx";
                Assert.Equal("test.docx", doc.Filename);
            }
        }
示例#7
0
        public void SaveNewDocumentInODF()
        {
            var fileName = string.Format("{0}\\{1}", FILE_PATH, FILE_NAME_ODF_FULL_DOCUMENT);
            var document = TextDocument.Create(fileName, true);

            AddAllContentToDocument(document);

            document.Save(DocumentType.ODFTextDocument);

            Assert.True(File.Exists(fileName), "File not saved");
        }
示例#8
0
        public void SaveDocumentFromTemplateFile()
        {
            var          templateLocation = string.Format("{0}\\{1}.{2}", TEMPLATE_PATH, TEMPLATE_NAME, TEMPLATE_EXTENSION);
            var          fileName         = string.Format("{0}\\{1}", FILE_PATH, FILE_NAME_WORD);
            TextDocument doc = TextDocument.Create(fileName, templateLocation, true);

            if (doc != null)
            {
                doc.Save(DocumentType.OOXMLTextDocument);
                Assert.True(File.Exists(fileName), "File not saved");
            }
        }
示例#9
0
        public void SaveDocumentFromTemplateWithOnlyRowsDefinedInTable()
        {
            using (var stream = new MemoryStream(_shakespeareFixtures.Default))
            {
                using (var reader = new StreamReader(stream))
                {
                    var doc = TextDocument.Create(stream);
                    doc.Filename = TEMPLATE_PATH + "\\Test.docx";

                    AddTableWithNoColumnDefinitionToDocument(doc, "Table 1");

                    doc.Save(DocumentType.OOXMLTextDocument);
                }
            }
        }
示例#10
0
        public void SaveNewDocumentInODFWithNoRowsOrCols()
        {
            var fileName = string.Format("{0}\\{1}", FILE_PATH, FILE_NAME_ODF);
            var document = TextDocument.Create(fileName, true);

            AddLinearTableToDocument(document, "Table 1");
            document.Tables[0].RemoveColumn(0);
            document.Tables[0].RemoveColumn(0);
            document.Tables[0].RemoveRow(0);
            document.Tables[0].RemoveRow(0);

            document.Save(DocumentType.ODFTextDocument);

            Assert.True(File.Exists(fileName), "File not saved");
        }
示例#11
0
        public void CreateDocumentFromTemplateStream()
        {
            using (var stream = new MemoryStream(_shakespeareFixtures.Default))
            {
                using (var reader = new StreamReader(stream))
                {
                    var doc = TextDocument.Create(stream);

                    Assert.NotNull(doc);
                    if (doc != null)
                    {
                        doc.Filename = "test.docx";
                        Assert.Equal("test.docx", doc.Filename);
                    }
                }
            }
        }
示例#12
0
        public void SaveDocumentFromTemplateStream()
        {
            using (var stream = new MemoryStream(_shakespeareFixtures.Default))
            {
                using (var reader = new StreamReader(stream))
                {
                    var doc = TextDocument.Create(stream);

                    Assert.NotNull(doc);
                    if (doc != null)
                    {
                        var fileName = string.Format("{0}\\{1}", FILE_PATH, FILE_NAME_WORD);
                        doc.Filename = fileName;
                        doc.Save(DocumentType.OOXMLTextDocument);
                        Assert.True(File.Exists(fileName), "File not saved");
                    }
                }
            }
        }
示例#13
0
        public void SaveDocumentFromTemplateWithCustomTags()
        {
            using (var stream = new MemoryStream(_shakespeareFixtures.The_Sonnets_Template))
            {
                using (var reader = new StreamReader(stream))
                {
                    var doc = TextDocument.Create(stream);
                    doc.Filename = TEMPLATE_PATH + "\\Shakespeare Sonnets.docx";

                    doc.ReplaceCustomTag("Author", "W. Shakespeare");
                    doc.ReplaceCustomTag("Title", "The Sonnets");
                    doc.ReplaceCustomTag("AuthorImage", _shakespeareFixtures.Shakespeare);

                    doc.AddParagraph("Sonnet I", Sonnet1(), 1);
                    doc.AddParagraph("Sonnet II", Sonnet2(), "normal", "Heading1");

                    AddNumberedList(doc, string.Empty);
                    AddBulletList(doc, string.Empty);

                    doc.Save(DocumentType.OOXMLTextDocument);
                }
            }
        }
示例#14
0
        public void CreateNamedExistingDocument()
        {
            var filename = string.Format("{0}\\{1}.{2}", DOCUMENT_PATH, DOCUMENT_NAME, DOCUMENT_EXTENSION);

            Assert.Throws <FileNotFoundException>(() => TextDocument.Create(Path.GetFullPath(filename), false));
        }
示例#15
0
        public void SaveDocumentWithoutFilename()
        {
            var document = TextDocument.Create();

            Assert.Throws <FilenameEmptyException>(() => document.Save(DocumentType.OOXMLTextDocument));
        }