Пример #1
0
            public void TestContains()
            {
                var mixed = new object[] { "hi", 1, TestEnum.First };

                Assert.True(ArrayFunctions.Contains(mixed, "hi"));
                Assert.True(ArrayFunctions.Contains(mixed, 1));
                Assert.True(ArrayFunctions.Contains(mixed, TestEnum.First));
                Assert.True(ArrayFunctions.Contains(mixed, "First"));
                Assert.True(ArrayFunctions.Contains(mixed, 100));
                TestParser.AssertTemplate("true", "{{ value | array.contains 'First' }}", model: new ObjectModel {
                    Value = mixed
                });
                TestParser.AssertTemplate("true", "{{ value | array.contains 100 }}", model: new ObjectModel {
                    Value = mixed
                });
                TestParser.AssertTemplate("false", "{{ value | array.contains 'Second' }}", model: new ObjectModel {
                    Value = mixed
                });
                TestParser.AssertTemplate("false", "{{ value | array.contains 101 }}", model: new ObjectModel {
                    Value = mixed
                });
                TestParser.AssertTemplate("false", "{{ value | array.contains 'Third' }}", model: new ObjectModel {
                    Value = mixed
                });
            }
Пример #2
0
 public void TestMathRandomError()
 {
     TestParser.AssertTemplate("text(1,4) : error : minValue must be greater than maxValue", "{{ math.random 11 10 }}");
 }
Пример #3
0
 public void TestSliceAtError()
 {
     TestParser.AssertTemplate("text(1,17) : error : Invalid number of arguments `0` passed to `string.slice1` while expecting `2` arguments", "{{ string.slice1 }}");
 }
Пример #4
0
 public void TestSortNoError()
 {
     TestParser.AssertTemplate("true", "{{ [1,2] || array.sort }}");
 }
Пример #5
0
 public void TestLiquidWithAndArguments()
 {
     TestParser.AssertTemplate("tada : 1 + yoyo", "{% include 'with_arguments' with 'tada' var1: 1, var2: 'yoyo' %}", ScriptLang.Liquid);
 }
Пример #6
0
 public void TestLiquidFor()
 {
     TestParser.AssertTemplate("for_product: Orange for_product: Banana for_product: Apple for_product: Computer for_product: Mobile Phone for_product: Table for_product: Sofa ", "{% include 'for_product' for products %}", ScriptLang.Liquid);
 }
Пример #7
0
 public void TestLiquidArguments()
 {
     TestParser.AssertTemplate("1 + yoyo", "{% include 'arguments' var1: 1, var2: 'yoyo' %}", ScriptLang.Liquid);
 }
Пример #8
0
 public void TestLiquidNull()
 {
     TestParser.AssertTemplate("", "{% include a %}", ScriptLang.Liquid);
 }
Пример #9
0
 public void TestLiquidWith()
 {
     TestParser.AssertTemplate("with_product: Orange", "{% include 'with_product' with product %}", ScriptLang.Liquid);
 }
Пример #10
0
 public void TestNested()
 {
     TestParser.AssertTemplate("This is a header body This is a body_detail This is a footer", "{{ include 'nested_templates' }}");
 }
Пример #11
0
 public void TestRecursiveNested()
 {
     TestParser.AssertTemplate("56789", "{{ include 'recursive_nested_templates' 5 }}");
 }
Пример #12
0
 public void TestProduct()
 {
     TestParser.AssertTemplate("product: Orange", "{{ include 'product' }}");
 }
Пример #13
0
 public void TestArguments()
 {
     TestParser.AssertTemplate("1 + 2", "{{ include 'arguments' 1 2 }}");
 }
Пример #14
0
 public void TestSimple()
 {
     TestParser.AssertTemplate("Test with a include yoyo", "Test with a include {{ include 'yoyo' }}");
 }
Пример #15
0
 public void TestLiquidNull()
 {
     TestParser.AssertTemplate("", "{% include a %}", true);
 }
Пример #16
0
 public void TestSortError()
 {
     TestParser.AssertTemplate("text(1,19) : error : Invalid number of arguments `0` passed to `array.sort` while expecting at least `1` arguments", "{{ [1,2] || array.sort }}");
 }