Example #1
0
        public CachedEvaluator(ISyntaxTreeBuilderFacade treeBuilder, List <Expression> expressions)
        {
            this.treeBuilder = treeBuilder;

            expressions.ForEach(e => cache.Add(e.Id, treeBuilder.Build(e.ExpressionString)));
        }
Example #2
0
        public void Should_Build_Simple_Numeric_Syntax_Tree()
        {
            Assert.True(builder.Build("1 = 1").Evaluate(null));
            Assert.True(builder.Build("1 < 2").Evaluate(null));
            Assert.True(builder.Build("2 <= 2").Evaluate(null));
            Assert.True(builder.Build("2 >= 2").Evaluate(null));
            Assert.True(builder.Build("2 > 1").Evaluate(null));
            Assert.True(builder.Build("1 != 2").Evaluate(null));

            Assert.False(builder.Build("1 != 1").Evaluate(null));
            Assert.False(builder.Build("1 > 2").Evaluate(null));
            Assert.False(builder.Build("1 >= 2").Evaluate(null));
            Assert.False(builder.Build("2 <= 1").Evaluate(null));
            Assert.False(builder.Build("2 < 1").Evaluate(null));
            Assert.False(builder.Build("1 = 2").Evaluate(null));
        }