Ejemplo n.º 1
0
        protected override bool IsValidContext(IStatementContext context)
        {
            bool isType = context.Parents.FirstParentIsOfType <ClassStatement>();
            bool isNext = context.IsNextToken <OpenCurlyBracketToken>() == false;

            return(isType && isNext);
        }
Ejemplo n.º 2
0
        public void MemberStatementFactoryShouldNotCreateProperty()
        {
            Expect.Call(_context.Parents).Return(new[] { new StatementParent(StatementCreator.CreateClassStatement(), StatementCreator.CreateOpenBlockStatement()) }).Repeat.Once();
            Expect.Call(_context.IsNextToken <OpenCurlyBracketToken>()).Return(true).Repeat.Once();

            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <PublicModifierToken>());
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("String"));
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("t"));

            Mocker.ReplayAll();
            Assert.IsFalse(_factory.CanCreateStatementFrom(input, _context));
            Mocker.VerifyAll();
        }