예제 #1
0
        public void NextTokenShouldNotReturnWhiteSpaceToken()
        {
            TokenBase identifier = TokenCreator.Create <IdentifierToken>("test");
            TokenBase space      = TokenCreator.Create <SpaceToken>();

            StatementBase classStatement  = StatementCreator.CreateClassStatement();
            StatementBase memberStatement = StatementCreator.CreateMemberStatement("test");

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

            foreach (TokenBase aToken in classStatement.Tokens)
            {
                totalList.Add(aToken);
            }
            foreach (TokenBase aToken in memberStatement.Tokens)
            {
                totalList.Add(aToken);
            }
            totalList.Add(space);
            totalList.Add(identifier);

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

            identifierList.Add(space);
            identifierList.Add(identifier);

            _manager.Encountered(new[] { classStatement }, classStatement.Tokens.Count(), totalList);
            Assert.AreEqual(identifier, _manager.GetContext(memberStatement.Tokens).NextTokenFromCurrentStatement);
        }
예제 #2
0
        public void FileBlockFactoryReturnedBlockStatementsShouldBeAllStatements()
        {
            IList <StatementBase> input = new List <StatementBase>();

            input.Add(StatementCreator.CreateMemberStatement("_this"));
            input.Add(StatementCreator.CreateMemberStatement("_that"));

            CollectionAssert.AreEquivalent(input, _factory.Create(input).ElementAt(0).Statements);
        }
예제 #3
0
        public void StatementParentsShouldBeEqual()
        {
            StatementBase alphaStatement = StatementCreator.CreateMemberStatement("test");
            StatementBase alphaDelimiter = StatementCreator.CreateOpenBlockStatement();

            TokenCreator.Reset();
            StatementBase bravoStatement = StatementCreator.CreateMemberStatement("test");
            StatementBase bravoDelimiter = StatementCreator.CreateOpenBlockStatement();

            StatementParent alpha = new StatementParent(new[] { alphaStatement }, alphaDelimiter);
            StatementParent bravo = new StatementParent(new[] { bravoStatement }, bravoDelimiter);

            Assert.AreEqual(alpha, bravo);
        }
예제 #4
0
        public void ParserShouldCallSBlockFactoryWhenParsingStatements()
        {
            IList <StatementBase> input = new List <StatementBase>();

            input.Add(StatementCreator.CreateMemberStatement("_someString"));

            IBlockFactory factory = Mocker.StrictMock <IBlockFactory>();

            Expect.Call(factory.Create(input)).Return(new [] { new BlockBaseImpl(input) }).Repeat.Once();

            StubBlockFactoryProvider provider = new StubBlockFactoryProvider(factory);

            CalidusBlockParser parser = new CalidusBlockParser(provider);

            Mocker.ReplayAll();

            parser.Parse(input);

            Mocker.VerifyAll();
        }
예제 #5
0
 public override void SetUp()
 {
     base.SetUp();
     _statement = StatementCreator.CreateMemberStatement("member");
 }
예제 #6
0
        public void RuleShouldReturnInvalidForStatementsThatDoNotMatchThePattern()
        {
            MemberNameMatchesPatternRule rule = new MemberNameMatchesPatternRule(new Regex("^_[a-z]+"), false);

            Assert.IsFalse(rule.IsValidFor(StatementCreator.CreateMemberStatement("ATest")));
        }
예제 #7
0
        public void RuleShouldValidateStatements()
        {
            MemberNameMatchesPatternRule rule = new MemberNameMatchesPatternRule(new Regex(""), false);

            Assert.IsTrue(rule.Validates(StatementCreator.CreateMemberStatement("member")));
        }
 public void ExplicitAccessModifierRuleShouldValidateMembers()
 {
     Assert.IsTrue(_rule.Validates(StatementCreator.CreateMemberStatement("test")));
 }