//[TestCase(@"{% assign arrayEmpty = """" | split: "","" %}{% if arrayEmpty == present %}TRUTHY X{% else %}FALSY{% endif %}", @"", @"FALSY")] //[TestCase(@"{% assign arrayEmpty = """" | split: "","" %}{% if arrayEmpty.empty? %}TRUTHY{% else %}FALSY X{% endif %}", @"", @"FALSY X")] //[TestCase(@"{% assign arrayEmpty = """" | split: "","" %}{% if arrayEmpty.blank? %}TRUTHY{% else %}FALSY X{% endif %}", @"", @"FALSY X")] //[TestCase(@"{% assign arrayEmpty = """" | split: "","" %}{% if arrayEmpty.present? %}TRUTHY X{% else %}FALSY{% endif %}", @"", @"FALSY")] public void It_Should_Match_Ruby_Output(String input, String assigns, String expected) { // Arrange ITemplateContext ctx = new TemplateContext().WithAllFilters(); foreach (var tuple in DictionaryFactory.CreateStringMapFromJson(assigns)) { ctx.DefineLocalVariable(tuple.Item1, tuple.Item2); } var template = LiquidTemplate.Create(input); // Act String result = template.LiquidTemplate.Render(ctx).Result; // Assert Assert.That(result.Trim(), Is.EqualTo(expected)); }
public void It_Should_Convert_A_Dictionary_Containing_An_Array() { // Arrange String json = "{\"array\": [1,2,3]}"; // Act IList <Tuple <String, Option <ILiquidValue> > > result = DictionaryFactory.CreateStringMapFromJson(json); // Assert //Logger.Log(result); Assert.That(result[0].Item1, Is.EqualTo("array")); Assert.That(result[0].Item2.Value, Is.TypeOf <LiquidCollection>()); var array = (LiquidCollection)result[0].Item2.Value; Assert.That(array.Select(x => x.Value.Value), Is.EquivalentTo(new List <int> { 1, 2, 3 })); }