Example #1
0
        public void ExpressionContainsNoShouldMatchAppropriateTokenList()
        {
            IList <TokenBase> input = new List <TokenBase>();

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

            IStatementExpression toMatch = _expression.ContainsNo <SemiColonToken>();

            Assert.IsTrue(toMatch.Matches(input));
        }
Example #2
0
        public void ExpressionStartWithShouldMatchAppropriateTokenList()
        {
            IList <TokenBase> input = new List <TokenBase>();

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

            IStatementExpression toMatch = _expression.StartsWith <SemiColonToken>();

            Assert.IsTrue(toMatch.Matches(input));
        }
Example #3
0
        public void ExpressionStartWithShouldNotMatchUnAppropriateTokenList()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <SemiColonToken>());
            input.Add(TokenCreator.Create <GenericToken>("content", null));

            IStatementExpression toMatch = _expression.StartsWith <GenericToken>();

            Assert.IsFalse(toMatch.Matches(input));
        }
Example #4
0
        public void ExpressionIsShouldMatchSingleTokenTypeWithWhiteSpace()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <TabToken>());
            input.Add(TokenCreator.Create <ClassToken>());
            input.Add(TokenCreator.Create <SpaceToken>());

            IStatementExpression toMatch =
                _expression.Is <ClassToken>();

            Assert.IsTrue(toMatch.Matches(input));
        }
Example #5
0
        public void ExpressionEndsWithShouldMatchAppropriateTokenListIgnoringWhitespace()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <PrivateModifierToken>());
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <NewLineToken>());
            input.Add(TokenCreator.Create <TabToken>());

            IStatementExpression toMatch = _expression.EndsWith <PrivateModifierToken>();

            Assert.IsTrue(toMatch.Matches(input));
        }
Example #6
0
        public void ExpressionIsShouldNotMatchDifferentTokenTypes()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <TabToken>());
            input.Add(TokenCreator.Create <ClassToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("test"));
            input.Add(TokenCreator.Create <SpaceToken>());

            IStatementExpression toMatch =
                _expression.Is <ClassToken>();

            Assert.IsFalse(toMatch.Matches(input));
        }
Example #7
0
        public void ExpressionIsShouldNotMatchMultipleInstancesOfSingleTokenType()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <TabToken>());
            input.Add(TokenCreator.Create <ClassToken>());
            input.Add(TokenCreator.Create <ClassToken>());
            input.Add(TokenCreator.Create <SpaceToken>());

            IStatementExpression toMatch =
                _expression.Is <ClassToken>();

            Assert.IsFalse(toMatch.Matches(input));
        }
Example #8
0
        public void ExpressionStartWithAndFollowedByStrictShouldNotIgnoreWhiteSpace()
        {
            IList <TokenBase> input = new List <TokenBase>();

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

            IStatementExpression toMatch =
                _expression.StartsWith <PrivateModifierToken>()
                .FollowedByStrict <SemiColonToken>();

            Assert.IsFalse(toMatch.Matches(input));
        }
Example #9
0
        public void ExpressionEndsWithShouldMatchAppropriateTokenList()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <PrivateModifierToken>());
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("String"));
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("variable"));
            input.Add(TokenCreator.Create <SemiColonToken>());

            IStatementExpression toMatch = _expression.EndsWith <SemiColonToken>();

            Assert.IsTrue(toMatch.Matches(input));
        }
Example #10
0
        public void ExpressionStartWithAndFollowedByShouldMatchAppropriateTokenListIgnoringWhiteSpaceTokens()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <PrivateModifierToken>());
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <NewLineToken>());
            input.Add(TokenCreator.Create <TabToken>());
            input.Add(TokenCreator.Create <SemiColonToken>());

            IStatementExpression toMatch =
                _expression.StartsWith <PrivateModifierToken>()
                .FollowedBy <SemiColonToken>();

            Assert.IsTrue(toMatch.Matches(input));
        }
Example #11
0
        public void ExpressionShouldCheckEntireTokenListEvenIfFirstMatchWasInvalid()
        {
            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <PrivateModifierToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("notvalid"));
            input.Add(TokenCreator.Create <SemiColonToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("identifier"));
            input.Add(TokenCreator.Create <PrivateModifierToken>());
            input.Add(TokenCreator.Create <SemiColonToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("ending"));

            IStatementExpression toMatch =
                _expression.Contains <PrivateModifierToken>()
                .FollowedBy <SemiColonToken>();

            Assert.IsTrue(toMatch.Matches(input));
        }
Example #12
0
        public void EmptyExpressionShouldNotMatch()
        {
            IList <TokenBase> input = new List <TokenBase>();

            Assert.IsFalse(_expression.Matches(input));
        }