Exemple #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
                });
            }