Skip to content

Commit 6976edb

Browse files
committed
Update test case to cheack formatter support
1 parent 3aa64ed commit 6976edb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

DocxTemplater.Test/DocxTemplateTest.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,11 +1335,12 @@ public void TestWithBaseTemplateModelWithDisplayNames()
13351335

13361336
MainDocumentPart mainPart = wpDocument.AddMainDocumentPart();
13371337
mainPart.Document = new Document(new Body(new Paragraph(
1338-
new Run(new Text("{{ds.MyString}} + {{ds.SomeNumber}}"))
1338+
new Run(new Text("{{ds.Vorname}} {{ds.LastName}} aus {{ds.Anschrift}}"))
13391339
)));
13401340
wpDocument.Save();
13411341
memStream.Position = 0;
13421342
var docTemplate = new DocxTemplate(memStream);
1343+
docTemplate.RegisterFormatter(new Markdown.MarkdownFormatter());
13431344
docTemplate.BindModel("ds", new DummyModelWithDisplayNames());
13441345
var result = docTemplate.Process();
13451346
docTemplate.Validate();
@@ -1348,7 +1349,7 @@ public void TestWithBaseTemplateModelWithDisplayNames()
13481349

13491350
var document = WordprocessingDocument.Open(result, false);
13501351
var body = document.MainDocumentPart.Document.Body;
1351-
Assert.That(body.InnerText, Is.EqualTo("Hello World! + 42"));
1352+
Assert.That(body.InnerText, Is.EqualTo("John Doe aus Musterstraße 42, A-4242 Musterhausen"));
13521353
}
13531354

13541355
private static DriveStudentOverviewReportingModel CrateBillTemplate2Model()
@@ -1520,10 +1521,14 @@ public bool TryGetPropertyValue(string propertyName, out ValueWithMetadata value
15201521

15211522
private class DummyModelWithDisplayNames : TemplateModelWithDisplayNames
15221523
{
1523-
[DisplayName("MyString")]
1524-
public string SomeString { get; set; } = "Hello World!";
1524+
[DisplayName("Vorname")]
1525+
public string FirstName { get; set; } = "John";
1526+
1527+
public string LastName { get; set; } = "Doe";
15251528

1526-
public int SomeNumber { get; set; } = 42;
1529+
[DisplayName("Anschrift")]
1530+
[ModelProperty(DefaultFormatter = "md")]
1531+
public string Address { get; set; } = "Musterstraße 42, **A-4242 Musterhausen**";
15271532
}
15281533
}
15291534
}

0 commit comments

Comments
 (0)