aboutsummaryrefslogtreecommitdiff
path: root/dotnet/Mammoth.Tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-04-30 16:53:16 +0100
committerMichael Williamson <mike@zwobble.org>2016-04-30 16:53:16 +0100
commitd71b9ef7b2ed7d72df132b5e38448fbbac7036be (patch)
treeb872d6a4aeac5f043a61bb0a856ec85e202469a3 /dotnet/Mammoth.Tests
parentff98a9a2804d5e7c042d6bb400cd9265cf00fa85 (diff)
Produce nicer error messages in C#
Diffstat (limited to 'dotnet/Mammoth.Tests')
-rw-r--r--dotnet/Mammoth.Tests/DocumentConverterTests.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/dotnet/Mammoth.Tests/DocumentConverterTests.cs b/dotnet/Mammoth.Tests/DocumentConverterTests.cs
index 89ade1c..92a3adf 100644
--- a/dotnet/Mammoth.Tests/DocumentConverterTests.cs
+++ b/dotnet/Mammoth.Tests/DocumentConverterTests.cs
@@ -151,13 +151,24 @@ namespace Mammoth.Tests {
}
[Fact]
- public void RulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverriden() {
+ public void RulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverridden() {
AssertSuccessfulConversion(
ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("strike => del")),
"<p><strong>The <em>Sunset</em> Tree</strong></p>");
}
[Fact]
+ public void ErrorIsRaisedIfStyleMapCannotBeParsed() {
+ var exception = Assert.ThrowsAny<Exception>(() =>
+ new DocumentConverter().AddStyleMap("p =>\np[style-name=] =>"));
+ Assert.Equal(
+ "error reading style map at line 2, character 14: expected token of type _STRING but was of type _CLOSE_SQUARE_BRACKET\n\n" +
+ "p[style-name=] =>\n" +
+ " ^",
+ exception.Message);
+ }
+
+ [Fact]
public void CanDisableDefaultStyleMap() {
var result = ConvertToHtml("simple-list.docx", mammoth => mammoth.DisableDefaultStyleMap());
Assert.Equal(new[]{"Unrecognised paragraph style: List Paragraph (Style ID: ListParagraph)"}, result.Warnings);