コード例 #1
0
        public void ParserShouldCallCompiler()
        {
            var lexer  = MockRepository.GenerateStub <ILexer>();
            var tokens = new List <Token>();

            lexer.Stub(x => x.Tokenize("ABC")).Return(tokens);
            var expectedGraph = new ExGraph();

            expectedGraph.Add(new StringExpression("asdf"));
            var graphBuilder = MockRepository.GenerateStub <IExpressionGraphBuilder>();

            graphBuilder.Stub(x => x.Build(tokens)).Return(expectedGraph);
            var compiler = MockRepository.GenerateStub <IExpressionCompiler>();

            compiler.Stub(x => x.Compile(expectedGraph.Expressions)).Return(new CompileResult(0, DataType.Integer));

            _parser.Configure(config =>
            {
                config
                .SetLexer(lexer)
                .SetGraphBuilder(graphBuilder)
                .SetExpresionCompiler(compiler);
            });

            _parser.Parse("ABC");

            compiler.AssertWasCalled(x => x.Compile(expectedGraph.Expressions));
        }
コード例 #2
0
        public void ParserShouldCallCompiler()
        {
            var lexer = MockRepository.GenerateStub<ILexer>();
            var tokens = new List<Token>();
            lexer.Stub(x => x.Tokenize("ABC")).Return(tokens);
            var expectedGraph = new ExGraph();
            expectedGraph.Add(new StringExpression("asdf"));
            var graphBuilder = MockRepository.GenerateStub<IExpressionGraphBuilder>();
            graphBuilder.Stub(x => x.Build(tokens)).Return(expectedGraph);
            var compiler = MockRepository.GenerateStub<IExpressionCompiler>();
            compiler.Stub(x => x.Compile(expectedGraph.Expressions)).Return(new CompileResult(0, DataType.Integer));

            _parser.Configure(config =>
            {
                config
                    .SetLexer(lexer)
                    .SetGraphBuilder(graphBuilder)
                    .SetExpresionCompiler(compiler);
            });

            _parser.Parse("ABC");

            compiler.AssertWasCalled(x => x.Compile(expectedGraph.Expressions));
        }
コード例 #3
0
 public void Setup()
 {
     _expressionCompiler = new ExpressionCompiler();
     _graph = new ExpGraph();
 }
コード例 #4
0
 public void Setup()
 {
     _expressionCompiler = new ExpressionCompiler();
     _graph = new ExpGraph();
 }