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)); }
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)); }
public EditTextDocumentTests(ShakespeareFixtures shakespeareFixtures) { _shakespeareFixtures = shakespeareFixtures; _document = TextDocument.Create(); _paragraphId = Guid.NewGuid().ToString(); }
public void CreateNamedDocument() { TextDocument doc = TextDocument.Create("test.docx", true); Assert.NotNull(doc); if (doc != null) { Assert.Equal("test.docx", doc.Filename); } }
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); } }
public void CreateEmptyDocument() { TextDocument doc = TextDocument.Create(); Assert.NotNull(doc); if (doc != null) { doc.Filename = "test.docx"; Assert.Equal("test.docx", doc.Filename); } }
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"); }
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"); } }
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); } } }
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"); }
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); } } } }
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"); } } } }
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); } } }
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)); }
public void SaveDocumentWithoutFilename() { var document = TextDocument.Create(); Assert.Throws <FilenameEmptyException>(() => document.Save(DocumentType.OOXMLTextDocument)); }