Esempio n. 1
0
        public void ParserShouldCallStatementFactoryAndContextManagerWhenParsingTokens()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <GenericToken>("source", null));
            input.Add(TokenCreator.Create <GenericToken>("code", null));

            IStatementFactory        factory        = Mocker.StrictMock <IStatementFactory>();
            IStatementContext        context        = Mocker.StrictMock <IStatementContext>();
            IStatementContextManager contextManager = Mocker.StrictMock <IStatementContextManager>();

            Expect.Call(factory.CanCreateStatementFrom(new List <TokenBase>(), context)).IgnoreArguments().Return(true).Repeat.Once();
            Expect.Call(factory.Create(input, context)).Return(new GenericStatement(input, context)).Repeat.Once();
            Expect.Call(() => contextManager.Encountered(new[] { new GenericStatement(input, context) }, input.Count, input)).Repeat.Once();
            Expect.Call(contextManager.GetContext(input)).Return(context).Repeat.Once();

            input.Add(TokenCreator.Create <SemiColonToken>());

            StubStatementFactoryProvider provider = new StubStatementFactoryProvider(factory);
            CalidusStatementParser       parser   = new CalidusStatementParser(provider, contextManager);

            Mocker.ReplayAll();

            parser.Parse(input);

            Mocker.VerifyAll();
        }
Esempio n. 2
0
        public override void SetUp()
        {
            base.SetUp();

            IStatementContextManager contextManager = Mocker.DynamicMock <IStatementContextManager>();

            _parser = new CalidusStatementParser(new StubStatementFactoryProvider(), contextManager);
            Mocker.ReplayAll();
        }
Esempio n. 3
0
 /// <summary>
 /// Create a new instance of this class
 /// </summary>
 /// <param name="statementFactoryProvider">The statement factory provider to use</param>
 /// <param name="contextManager">The context manager</param>
 public CalidusStatementParser(IStatementFactoryProvider statementFactoryProvider, IStatementContextManager contextManager)
 {
     _statementFactoryProvider = statementFactoryProvider;
     _contextManager           = contextManager;
 }