File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed
Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 11namespace RazorEngineCore . Tests . Models
22{
3- public class TestTemplate2 : RazorEngineTemplateBase < TestModel >
4- {
5- public void Initialize ( TestModel model )
3+ public class TestTemplate2 : RazorEngineTemplateBase < TestModel >
64 {
7- this . Model = model ;
5+ public void Initialize ( TestModel model )
6+ {
7+ this . Model = model ;
8+ }
89 }
9- }
1010}
Original file line number Diff line number Diff line change @@ -442,6 +442,28 @@ public void TestCompileAndRun_TypedModel2()
442442 Assert . AreEqual ( "Hello -=Alex=-" , actual ) ;
443443 }
444444
445+ [ TestMethod ]
446+ public void TestCompileAndRun_TypedModel3 ( )
447+ {
448+ string templateText = @"
449+ @inherits RazorEngineCore.RazorEngineTemplateBase<RazorEngineCore.Tests.Models.TestModel>
450+ Hello @Model.Decorator(Model.C)
451+ " ;
452+
453+ RazorEngine razorEngine = new RazorEngine ( ) ;
454+ IRazorEngineCompiledTemplate < RazorEngineTemplateBase < TestModel > > template = razorEngine . Compile < RazorEngineTemplateBase < TestModel > > ( templateText ) ;
455+
456+ string actual = template . Run ( instance =>
457+ {
458+ instance . Model = new TestModel
459+ {
460+ C = "Alex"
461+ } ;
462+ } ) ;
463+
464+ Assert . AreEqual ( "Hello -=Alex=-" , actual . Trim ( ) ) ;
465+ }
466+
445467 [ TestMethod ]
446468 public async Task TestCompileAndRun_TypedModel2Async ( )
447469 {
You can’t perform that action at this time.
0 commit comments