Example #1
0
        public void CloseBlockStatementShouldSetParentToTopParent()
        {
            ClassStatement classStatement = StatementCreator.CreateClassStatement();

            _manager.Encountered(new[] { classStatement }, TokenCreator.Created().Count(), TokenCreator.Created());

            OpenBlockStatement openBlock = StatementCreator.CreateOpenBlockStatement();

            _manager.Encountered(new[] { openBlock }, TokenCreator.Created().Count(), TokenCreator.Created());

            ClassStatement internalClassStatement = StatementCreator.CreateClassStatement();

            _manager.Encountered(new[] { internalClassStatement }, TokenCreator.Created().Count(), TokenCreator.Created());

            OpenBlockStatement secondOpenBlock = StatementCreator.CreateOpenBlockStatement();

            _manager.Encountered(new[] { secondOpenBlock }, TokenCreator.Created().Count(), TokenCreator.Created());

            CloseBlockStatement closeBlock = StatementCreator.CreateCloseBlockStatement();

            CollectionAssert.AreEquivalent(new[] { new StatementParent(new[] { classStatement }, openBlock), new StatementParent(new[] { internalClassStatement }, secondOpenBlock) }, _manager.GetContext(closeBlock.Tokens).Parents);
            _manager.Encountered(new[] { closeBlock }, TokenCreator.Created().Count(), TokenCreator.Created());

            CollectionAssert.AreEquivalent(new[] { new StatementParent(new[] { classStatement }, openBlock) }, _manager.GetContext(openBlock.Tokens).Parents);
            _manager.Encountered(new[] { closeBlock }, TokenCreator.Created().Count(), TokenCreator.Created());
        }
Example #2
0
        public void CloseBlockStatementShouldEndParentContext()
        {
            ClassStatement classStatement = StatementCreator.CreateClassStatement();

            _manager.Encountered(new[] { classStatement }, TokenCreator.Created().Count(), TokenCreator.Created());
            Assert.AreEqual(0, _manager.GetContext(classStatement.Tokens).Parents.Count());

            OpenBlockStatement openBlock = StatementCreator.CreateOpenBlockStatement();

            _manager.Encountered(new[] { openBlock }, TokenCreator.Created().Count(), TokenCreator.Created());
            Assert.AreEqual(new[] { new StatementParent(new[] { classStatement }, openBlock) }, _manager.GetContext(openBlock.Tokens).Parents);

            CloseBlockStatement closeBlock = StatementCreator.CreateCloseBlockStatement();

            _manager.Encountered(new[] { closeBlock }, TokenCreator.Created().Count(), TokenCreator.Created());
            Assert.AreEqual(0, _manager.GetContext(closeBlock.Tokens).Parents.Count());
        }