Skip to content

Commit 959a0ff

Browse files
committed
TestCompileAndRun_TypedModel3 - test for @inherits
1 parent 311ec75 commit 959a0ff

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
namespace 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
}

RazorEngineCore.Tests/TestCompileAndRun.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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
{

0 commit comments

Comments
 (0)