public void ParserShouldCallCompiler() { var lexer = A.Fake <ILexer>(); var tokens = new List <Token>(); A.CallTo(() => lexer.Tokenize("ABC")).Returns(tokens); var expectedGraph = new ExGraph(); expectedGraph.Add(new StringExpression("asdf")); var graphBuilder = A.Fake <IExpressionGraphBuilder>(); A.CallTo(() => graphBuilder.Build(tokens)).Returns(expectedGraph); var compiler = A.Fake <IExpressionCompiler>(); A.CallTo(() => compiler.Compile(expectedGraph.Expressions)).Returns(new CompileResult(0, DataType.Integer)); _parser.Configure(config => { config .SetLexer(lexer) .SetGraphBuilder(graphBuilder) .SetExpresionCompiler(compiler); }); _parser.Parse("ABC"); A.CallTo(() => compiler.Compile(expectedGraph.Expressions)).MustHaveHappened(); }
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(); }
public void Setup() { _expressionCompiler = new ExpressionCompiler(); _graph = new ExpGraph(); }