|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
private readonly string _directoryDocuments;
|
|
|
private readonly string _directoryDocuments;
|
|
|
private const string FileTemp = "temp.docx";
|
|
|
|
|
|
private readonly string _directoryWithFiles;
|
|
|
private readonly string _directoryWithFiles;
|
|
|
private static Border BlankBorder = new Border(BorderStyle.Tcbs_none, 0, 0, Color.White);
|
|
|
private static Border BlankBorder = new Border(BorderStyle.Tcbs_none, 0, 0, Color.White);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DocXUnitTests()
|
|
|
public DocXUnitTests()
|
|
|
{
|
|
|
{
|
|
|
_directoryDocuments = Path.Combine((new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory)).Parent.FullName, "documents");
|
|
|
|
|
|
|
|
|
_directoryDocuments = Path.Combine(Path.GetTempPath(), "DocXTests", "documents");
|
|
|
Setup(_directoryDocuments); // prepare temp documents directory
|
|
|
Setup(_directoryDocuments); // prepare temp documents directory
|
|
|
|
|
|
|
|
|
_directoryWithFiles = TestHelper.DirectoryWithFiles;
|
|
|
_directoryWithFiles = TestHelper.DirectoryWithFiles;
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|
|
|
public void Test_Document_Paragraphs()
|
|
|
public void Test_Document_Paragraphs()
|
|
|
{
|
|
|
{
|
|
|
|
|
|
string temporaryFilePath = Path.Combine(_directoryDocuments, "temp.docx");
|
|
|
|
|
|
|
|
|
// Load the document 'Paragraphs.docx'
|
|
|
// Load the document 'Paragraphs.docx'
|
|
|
using (DocX document = DocX.Load(Path.Combine(_directoryWithFiles, "Paragraphs.docx")))
|
|
|
using (DocX document = DocX.Load(Path.Combine(_directoryWithFiles, "Paragraphs.docx")))
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
Assert.IsTrue(paragraph.PackagePart.Uri.ToString() == package_part_document);
|
|
|
Assert.IsTrue(paragraph.PackagePart.Uri.ToString() == package_part_document);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test the saving of the document.
|
|
|
// Test the saving of the document.
|
|
|
document.SaveAs(FileTemp);
|
|
|
|
|
|
|
|
|
document.SaveAs(temporaryFilePath);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// Delete the tempory file.
|
|
|
// Delete the tempory file.
|
|
|
File.Delete(FileTemp);
|
|
|
|
|
|
|
|
|
File.Delete(temporaryFilePath);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
[Test]
|