Skip to content

Commit d6ca867

Browse files
committed
Add test method for list of structs
1 parent ccf388f commit d6ca867

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

RazorEngineCore.Tests/TestCompileAndRun.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ public async Task TestCompileAndRun_DynamicModel_PlainAsync()
157157
Assert.AreEqual("Hello Alex", actual);
158158
}
159159

160+
public struct Item
161+
{
162+
public string Name { get; set; }
163+
}
164+
165+
[TestMethod]
166+
public void TestCompileAndRun_StructList()
167+
{
168+
var eng = new RazorEngine();
169+
var model = new
170+
{
171+
Items = new[] { new Item { Name = "Bob" }, new Item { Name = "Alice" } }
172+
};
173+
var temp = eng.Compile("@foreach(var item in Model.Items) { @item.Name }");
174+
var result = temp.Run(model);
175+
Assert.AreEqual("BobAlice", result);
176+
}
177+
160178
[TestMethod]
161179
public void TestCompileAndRun_DynamicModel_Nested()
162180
{

0 commit comments

Comments
 (0)