public void TestLoopNestedSimple() { var model = new LoopTestModel("root"); model.Children = new LoopTestModel[] { new LoopTestModel("Child1") { Children = new LoopTestModel[] { new LoopTestModel("Child11"), new LoopTestModel("Child12"), new LoopTestModel("Child13"), } }, new LoopTestModel("Child2"), new LoopTestModel("Child3") { Children = new LoopTestModel[] { new LoopTestModel("Child31"), new LoopTestModel("Child32"), } } }; const String template = TemplateContentPrefix + "[[ for(Children) ]]" + "[[ for(Children.Children) ]]" + "[[ Children.Children.Name ]]" + "[[ endfor(Children.Children) ]]" + "[[ endfor(Children) ]]" + TemplateContentSuffix; const String expectedResult = TemplateContentPrefix + "Child11" + "Child12" + "Child13" + "Child31" + "Child32" + TemplateContentSuffix; String actual = this.Engine.Process(template, model); Assert.AreEqual(expectedResult, actual); }
public void TestLoopWithindocuments() { var model = new LoopTestModel("root"); model.Children = "123".ToCharArray(); const String template = TemplateContentPrefix + "[[ Name ]] " + "[[ Children.Length]] " + "[[ for(Children) ]]" + "Child[[Children]] " + "[[ endfor(Children) ]]" + TemplateContentSuffix; const String expectedResult = TemplateContentPrefix + "root 3 Child1 Child2 Child3 " + TemplateContentSuffix; String actual = this.Engine.Process(template, model); Assert.AreEqual(expectedResult, actual); }
public void TestLoopSimple() { var model = new LoopTestModel("root"); model.Children = "123".ToCharArray(); const String template = TemplateContentPrefix + "[[ for(Children) ]]" + ExpectedValue + "[[ endfor(Children) ]]" + TemplateContentSuffix; const String expectedResult = TemplateContentPrefix + ExpectedValue + ExpectedValue + ExpectedValue + TemplateContentSuffix; String actual = this.Engine.Process(template, model); Assert.AreEqual(expectedResult, actual); }