|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void Saving_and_loading_a_template_should_work()
|
|
|
public void Saving_and_loading_a_template_should_work()
|
|
|
{
|
|
|
{
|
|
|
using (DocX document = DocX.Create("test template.dotx", DocumentTypes.Template))
|
|
|
|
|
|
|
|
|
using (DocX document = DocX.Create(Path.Combine(_directoryDocuments, "test template.dotx"), DocumentTypes.Template))
|
|
|
{
|
|
|
{
|
|
|
document.InsertParagraph("hello, this is a paragraph");
|
|
|
document.InsertParagraph("hello, this is a paragraph");
|
|
|
document.Save();
|
|
|
document.Save();
|
|
|
}
|
|
|
}
|
|
|
using (DocX document = DocX.Load("test template.dotx"))
|
|
|
|
|
|
|
|
|
using (DocX document = DocX.Load(Path.Combine(_directoryDocuments, "test template.dotx")))
|
|
|
{
|
|
|
{
|
|
|
Assert.IsTrue(document.Paragraphs.Count > 0);
|
|
|
Assert.IsTrue(document.Paragraphs.Count > 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void IfPreviousElementIsAListThenAddingANewListContinuesThePreviousList()
|
|
|
public void IfPreviousElementIsAListThenAddingANewListContinuesThePreviousList()
|
|
|
{
|
|
|
{
|
|
|
using (DocX document = DocX.Create("TestAddListToPreviousList.docx"))
|
|
|
|
|
|
|
|
|
using (DocX document = DocX.Create(Path.Combine(_directoryDocuments, "TestAddListToPreviousList.docx")))
|
|
|
{
|
|
|
{
|
|
|
var list = document.AddList("List Text");
|
|
|
var list = document.AddList("List Text");
|
|
|
document.AddListItem(list, "List Text2");
|
|
|
document.AddListItem(list, "List Text2");
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void WhenICreateAHeaderItShouldHaveAStyle()
|
|
|
public void WhenICreateAHeaderItShouldHaveAStyle()
|
|
|
{
|
|
|
{
|
|
|
using (var document = DocX.Create("CreateHeaderElement.docx"))
|
|
|
|
|
|
|
|
|
using (var document = DocX.Create(Path.Combine(_directoryDocuments, "CreateHeaderElement.docx")))
|
|
|
{
|
|
|
{
|
|
|
document.InsertParagraph("Header Text 1").StyleName = "Header1";
|
|
|
document.InsertParagraph("Header Text 1").StyleName = "Header1";
|
|
|
Assert.IsNotNull(document.styles.Root.Descendants().FirstOrDefault(d => d.GetAttribute(DocX.w + "styleId").ToLowerInvariant() == "heading1"));
|
|
|
Assert.IsNotNull(document.styles.Root.Descendants().FirstOrDefault(d => d.GetAttribute(DocX.w + "styleId").ToLowerInvariant() == "heading1"));
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void ParagraphAppendHyperLink_ParagraphIsListItem_ShouldNotThrow()
|
|
|
public void ParagraphAppendHyperLink_ParagraphIsListItem_ShouldNotThrow()
|
|
|
{
|
|
|
{
|
|
|
using (var document = DocX.Create("HyperlinkList.docx"))
|
|
|
|
|
|
|
|
|
using (var document = DocX.Create(Path.Combine(_directoryDocuments, "HyperlinkList.docx")))
|
|
|
{
|
|
|
{
|
|
|
var list = document.AddList("Item 1", listType: ListItemType.Numbered);
|
|
|
var list = document.AddList("Item 1", listType: ListItemType.Numbered);
|
|
|
document.AddListItem(list, "Item 2");
|
|
|
document.AddListItem(list, "Item 2");
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void InsertingANextPageBreakShouldAddADocumentSection()
|
|
|
public void InsertingANextPageBreakShouldAddADocumentSection()
|
|
|
{
|
|
|
{
|
|
|
using (DocX document = DocX.Create("SectionPageBreak.docx"))
|
|
|
|
|
|
|
|
|
using (DocX document = DocX.Create(Path.Combine(_directoryDocuments, "SectionPageBreak.docx")))
|
|
|
{
|
|
|
{
|
|
|
document.InsertSectionPageBreak();
|
|
|
document.InsertSectionPageBreak();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void InsertANextPageBreakWithParagraphTextsShouldAddProperParagraphsToProperSections()
|
|
|
public void InsertANextPageBreakWithParagraphTextsShouldAddProperParagraphsToProperSections()
|
|
|
{
|
|
|
{
|
|
|
using (DocX document = DocX.Create("SectionPageBreakWithParagraphs.docx"))
|
|
|
|
|
|
|
|
|
using (DocX document = DocX.Create(Path.Combine(_directoryDocuments, "SectionPageBreakWithParagraphs.docx")))
|
|
|
{
|
|
|
{
|
|
|
document.InsertParagraph("First paragraph.");
|
|
|
document.InsertParagraph("First paragraph.");
|
|
|
document.InsertParagraph("Second paragraph.");
|
|
|
document.InsertParagraph("Second paragraph.");
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void WhenAFontFamilyIsSpecifiedForAParagraphItShouldSetTheFontOfTheParagraphTextToTheFontFamily()
|
|
|
public void WhenAFontFamilyIsSpecifiedForAParagraphItShouldSetTheFontOfTheParagraphTextToTheFontFamily()
|
|
|
{
|
|
|
{
|
|
|
using (DocX document = DocX.Create("FontTest.docx"))
|
|
|
|
|
|
|
|
|
using (DocX document = DocX.Create(Path.Combine(_directoryDocuments, "FontTest.docx")))
|
|
|
{
|
|
|
{
|
|
|
Paragraph p = document.InsertParagraph();
|
|
|
Paragraph p = document.InsertParagraph();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void GenerateHeadingTestDocument()
|
|
|
public void GenerateHeadingTestDocument()
|
|
|
{
|
|
|
{
|
|
|
using (DocX document = DocX.Create(@"Document Header Test.docx"))
|
|
|
|
|
|
|
|
|
using (DocX document = DocX.Create(Path.Combine(_directoryDocuments, @"Document Header Test.docx")))
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
foreach (HeadingType heading in (HeadingType[])Enum.GetValues(typeof(HeadingType)))
|
|
|
foreach (HeadingType heading in (HeadingType[])Enum.GetValues(typeof(HeadingType)))
|