diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-04-26 21:58:27 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-04-26 21:58:27 +0100 |
| commit | 83ab30b58328602eb233522b8dea8d2f13f11f13 (patch) | |
| tree | 553e1077d79e7c282540b665e0620ca0f2d63052 | |
| parent | 73a6878e1869a2f742bba15364459ae0eea45962 (diff) | |
Add basic test
| -rw-r--r-- | dotnet/Mammoth.Tests/DocumentConverterTests.cs | 24 | ||||
| -rw-r--r-- | dotnet/Mammoth.Tests/Mammoth.Tests.csproj | 23 | ||||
| l--------- | dotnet/Mammoth.Tests/TestData | 1 | ||||
| -rw-r--r-- | dotnet/makefile | 7 |
4 files changed, 54 insertions, 1 deletions
diff --git a/dotnet/Mammoth.Tests/DocumentConverterTests.cs b/dotnet/Mammoth.Tests/DocumentConverterTests.cs index 112087a..5b53685 100644 --- a/dotnet/Mammoth.Tests/DocumentConverterTests.cs +++ b/dotnet/Mammoth.Tests/DocumentConverterTests.cs @@ -1,5 +1,27 @@ -namespace Mammoth.Tests { +using Xunit; +using System.IO; + +namespace Mammoth.Tests { public class DocumentConverterTests { + [Fact] + public void DocxContainingOneParagraphIsConvertedToSingleParagraphElement() { + assertSuccessfulConversion( + convertToHtml("single-paragraph.docx"), + "<p>Walking on imported air</p>"); + } + + private void assertSuccessfulConversion(IResult<string> result, string expectedValue) { + Assert.Empty(result.Warnings); + Assert.Equal(expectedValue, result.Value); + } + + private IResult<string> convertToHtml(string name) { + return new DocumentConverter().ConvertToHtml(TestFilePath(name)); + } + + private string TestFilePath(string name) { + return Path.Combine("../../TestData", name); + } } } diff --git a/dotnet/Mammoth.Tests/Mammoth.Tests.csproj b/dotnet/Mammoth.Tests/Mammoth.Tests.csproj index 89daf3b..d561dde 100644 --- a/dotnet/Mammoth.Tests/Mammoth.Tests.csproj +++ b/dotnet/Mammoth.Tests/Mammoth.Tests.csproj @@ -51,4 +51,27 @@ <ItemGroup> <None Include="packages.config" /> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="TestData\empty.docx" /> + <EmbeddedResource Include="TestData\endnotes.docx" /> + <EmbeddedResource Include="TestData\external-picture.docx" /> + <EmbeddedResource Include="TestData\footnote-hyperlink.docx" /> + <EmbeddedResource Include="TestData\footnotes.docx" /> + <EmbeddedResource Include="TestData\simple-list.docx" /> + <EmbeddedResource Include="TestData\single-paragraph.docx" /> + <EmbeddedResource Include="TestData\strikethrough.docx" /> + <EmbeddedResource Include="TestData\tables.docx" /> + <EmbeddedResource Include="TestData\text-box.docx" /> + <EmbeddedResource Include="TestData\tiny-picture.docx" /> + <EmbeddedResource Include="TestData\tiny-picture.png" /> + <EmbeddedResource Include="TestData\tiny-picture-custom-content-type.docx" /> + <EmbeddedResource Include="TestData\underline.docx" /> + <EmbeddedResource Include="TestData\utf8-bom.docx" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Mammoth\Mammoth.csproj"> + <Project>{51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}</Project> + <Name>Mammoth</Name> + </ProjectReference> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/dotnet/Mammoth.Tests/TestData b/dotnet/Mammoth.Tests/TestData new file mode 120000 index 0000000..f8f6221 --- /dev/null +++ b/dotnet/Mammoth.Tests/TestData @@ -0,0 +1 @@ +../../src/test/resources/test-data
\ No newline at end of file diff --git a/dotnet/makefile b/dotnet/makefile new file mode 100644 index 0000000..aeeb74b --- /dev/null +++ b/dotnet/makefile @@ -0,0 +1,7 @@ +.PHONY: build test + +build: + xbuild Mammoth.sln + +test: build + mono --debug packages/xunit.runner.console.2.1.0/tools/xunit.console.exe Mammoth.Tests/bin/Debug/Mammoth.Tests.dll -noshadow |
