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)); }
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)); }
public void Setup() { _expressionCompiler = new ExpressionCompiler(); _graph = new ExpGraph(); }