aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-04-26 22:11:52 +0100
committerMichael Williamson <mike@zwobble.org>2016-04-26 22:11:52 +0100
commit8a693ba3c705901dca9b92bc01af76244cc0aaf1 (patch)
tree3fea79afdc58d5ec8497b62030291a98132e4b8f
parent6eccc7a24d63aa084ffe407c421eefe8f18e8a83 (diff)
Add test for preserving empty paragraphs
-rw-r--r--dotnet/Mammoth.Tests/DocumentConverterTests.cs14
1 files changed, 13 insertions, 1 deletions
diff --git a/dotnet/Mammoth.Tests/DocumentConverterTests.cs b/dotnet/Mammoth.Tests/DocumentConverterTests.cs
index c467d74..ef216f3 100644
--- a/dotnet/Mammoth.Tests/DocumentConverterTests.cs
+++ b/dotnet/Mammoth.Tests/DocumentConverterTests.cs
@@ -1,6 +1,7 @@
using Xunit;
using System.IO;
using Xunit.Sdk;
+using System;
namespace Mammoth.Tests {
public class DocumentConverterTests {
@@ -25,6 +26,13 @@ namespace Mammoth.Tests {
"");
}
+ [Fact]
+ public void EmptyParagraphsArePreservedIfIgnoreEmptyParagraphsIsFalse() {
+ assertSuccessfulConversion(
+ ConvertToHtml("empty.docx", converter => converter.PreserveEmptyParagraphs()),
+ "<p></p>");
+ }
+
private void assertSuccessfulConversion(IResult<string> result, string expectedValue) {
if (result.Warnings.Count > 0) {
throw new XunitException("Unexpected warnings: " + string.Join(", ", result.Warnings));
@@ -33,7 +41,11 @@ namespace Mammoth.Tests {
}
private IResult<string> ConvertToHtml(string name) {
- return new DocumentConverter().ConvertToHtml(TestFilePath(name));
+ return ConvertToHtml(name, converter => converter);
+ }
+
+ private IResult<string> ConvertToHtml(string name, Func<DocumentConverter, DocumentConverter> configure) {
+ return configure(new DocumentConverter()).ConvertToHtml(TestFilePath(name));
}
private string TestFilePath(string name) {