public void It_Should_Allow_Tags_To_Span_Lines() { // Arrange var templateContext = new TemplateContext(); LiquidCollection liquidCollection = new LiquidCollection { DataFixtures.CreateDictionary(1, "Title 1", "Value 1 B"), DataFixtures.CreateDictionary(2, "Title 2", "Value 2 B"), DataFixtures.CreateDictionary(3, "Title 3", "Value 3 B"), DataFixtures.CreateDictionary(4, "Title 4", "Value 4 B"), }; templateContext.DefineLocalVariable("posts", liquidCollection); const string tmpl = @"{% for post in posts %}{{ post.field1 }}{% endfor %}"; String result = GenerateAndRender(tmpl, templateContext); // Act Logger.Log("result is " + result); // Assert Assert.Equal("Title 1Title 2Title 3Title 4", result); }
public LiquidCollection CreateArrayOfDicts() { // Arrange return(new LiquidCollection { DataFixtures.CreateDictionary(1, "Value 1 A", "Value 1 B"), DataFixtures.CreateDictionary(2, "Value 2 A", "Value 2 B"), DataFixtures.CreateDictionary(3, "Value 3 A", "Value 3 B"), DataFixtures.CreateDictionary(4, "Value 4 A", "Value 4 B"), }); }
public void It_Should_Dereference_Properties_Of_Array(String property, String expected) { // Arrange TemplateContext ctx = new TemplateContext(); var liquidCollection = DataFixtures.CreateArrayValue(); ctx.DefineLocalVariable("myarray", liquidCollection); String tmpl = "{{ myarray." + property + " }}"; // Act var result = RenderingHelper.RenderTemplate(tmpl, ctx); // Assert Assert.Equal(expected, result); }
public void It_Should_Dereference_Properties_Of_Dictionary(String property) { // Arrange TemplateContext ctx = new TemplateContext(); var dictValue = DataFixtures.CreateDictionary(1, "Property 1", "prop2"); ctx.DefineLocalVariable("mydict", dictValue); String tmpl = "{{ mydict." + property + " }}"; // Act var result = RenderingHelper.RenderTemplate(tmpl, ctx); // Assert Assert.Equal(dictValue.Count.ToString(), result); }
public void It_Should_Look_Up_DictionaryValues(String liquid, String expected) { // Arrange TemplateContext ctx = new TemplateContext(); var dictValue = DataFixtures.CreateDictionary(1, "Property 1", "prop2"); ctx.DefineLocalVariable("mydict", dictValue); String tmpl = "{{ " + liquid + " }}"; // Act var result = RenderingHelper.RenderTemplate(tmpl, ctx); Logger.Log(result); // Assert Assert.Equal(expected, result); }
public void It_Should_Look_Up_ArrayValues(String index, String expected) { // Arrange TemplateContext ctx = new TemplateContext(); var liquidCollection = DataFixtures.CreateArrayValue(); ctx.DefineLocalVariable("myarray", liquidCollection); String tmpl = "{{ myarray[" + index + "] }}"; // Act var result = RenderingHelper.RenderTemplate(tmpl, ctx); // Assert //var expected = ValueCaster.RenderAsString(liquidCollection.ArrValue[3]); Assert.Equal(expected, result); }