예제 #1
0
        public void StarQueryTokenDefaultTest()
        {
            StarToken starToken = new StarToken(null);

            this.Assert.AreEqual(QueryTokenKind.Star, starToken.Kind, "The InternalKind property has an unexpected value.");
            this.Assert.IsNull(starToken.NextToken, "The NextToken property should be null.");
        }
예제 #2
0
        public static StarToken ShouldBeStarToken(this QueryToken token)
        {
            Assert.NotNull(token);
            StarToken starToken = Assert.IsType <StarToken>(token);

            Assert.Equal(QueryTokenKind.Star, starToken.Kind);
            return(starToken);
        }
예제 #3
0
        /// <summary>
        /// Write the star token as URI part to this builder.
        /// </summary>
        /// <param name="star">To write as URI part.</param>
        private void WriteStar(StarToken star)
        {
            ExceptionUtils.CheckArgumentNotNull(star, "star");

            if (star.NextToken != null)
            {
                this.WriteQuery(star.NextToken);
                this.builder.Append(ExpressionConstants.SymbolForwardSlash);
            }

            this.builder.Append(UriQueryConstants.Star);
        }
예제 #4
0
 /// <summary>
 /// Visits a StarToken
 /// </summary>
 /// <param name="tokenIn">The StarToken to bind</param>
 /// <returns>A QueryNode bound to this StarToken</returns>
 public virtual T Visit(StarToken tokenIn)
 {
     throw new NotImplementedException();
 }
예제 #5
0
 private static void VerifyStarQueryTokensAreEqual(StarToken expected, StarToken actual, AssertionHandler assert)
 {
     VerifyQueryTokensAreEqual(expected.NextToken, actual.NextToken, assert);
 }
예제 #6
0
        public void NameIsAlwaysStar()
        {
            StarToken starToken = new StarToken(null);

            starToken.Identifier.Should().Be("*");
        }
예제 #7
0
        public void ParentIsSetCorrectly()
        {
            StarToken starToken = new StarToken(new LiteralToken(1));

            starToken.NextToken.ShouldBeLiteralQueryToken(1);
        }
예제 #8
0
        public void ParentCanBeNull()
        {
            StarToken starToken = new StarToken(null);

            starToken.NextToken.Should().BeNull();
        }
예제 #9
0
        public void ParentCanBeNull()
        {
            StarToken starToken = new StarToken(null);

            Assert.Null(starToken.NextToken);
        }
예제 #10
0
        public List <Token> Convert(string regexString)
        {
            var result           = new List <Token>();
            var currentCharIndex = 0;
            var length           = regexString.Length;

            while (currentCharIndex != length)
            {
                var   currentChar = regexString[currentCharIndex];
                Token toAdd;
                switch (currentChar)
                {
                case '(':
                    toAdd = new LeftBracketToken();
                    break;

                case ')':
                    toAdd = new RightBracketToken();
                    break;

                case '*':
                    toAdd = new StarToken();
                    break;

                case '|':
                    toAdd = new SumToken();
                    break;

                case '\\':
                    currentCharIndex++;
                    if (currentCharIndex == length)
                    {
                        throw new RegexParseException($"Backslash at the end of input escaping nothing.");
                    }

                    toAdd = new CharacterClassToken($"\\{regexString[currentCharIndex]}");
                    break;

                case '[':
                    currentCharIndex++;
                    var startingIndex = currentCharIndex;
                    while (currentCharIndex != length && regexString[currentCharIndex] != ']')
                    {
                        // Escape inside character class
                        if ('\\'.Equals(regexString[currentCharIndex]))
                        {
                            currentCharIndex++;
                        }

                        currentCharIndex++;
                    }

                    if (currentCharIndex == length)
                    {
                        throw new RegexParseException($"Character class not properly closed in {regexString}");
                    }

                    var value = regexString.Substring(startingIndex, currentCharIndex - startingIndex);
                    toAdd = new CharacterClassToken(value);
                    break;

                default:
                    toAdd = new CharacterClassToken($"\\{currentChar}");
                    break;
                }

                result.Add(toAdd);
                currentCharIndex++;
            }

            return(result);
        }
 public void StarQueryTokenDefaultTest()
 {
     StarToken starToken = new StarToken(null);
     this.Assert.AreEqual(QueryTokenKind.Star, starToken.Kind, "The InternalKind property has an unexpected value.");
     this.Assert.IsNull(starToken.NextToken, "The NextToken property should be null.");
 }
예제 #12
0
 public void NameIsAlwaysStar()
 {
     StarToken starToken = new StarToken(null);
     starToken.Identifier.Should().Be("*");
 }
예제 #13
0
 public void ParentIsSetCorrectly()
 {
     StarToken starToken = new StarToken(new LiteralToken(1));
     starToken.NextToken.ShouldBeLiteralQueryToken(1);
 }
예제 #14
0
 public void ParentCanBeNull()
 {
     StarToken starToken = new StarToken(null);
     starToken.NextToken.Should().BeNull();
 }
예제 #15
0
        public void NameIsAlwaysStar()
        {
            StarToken starToken = new StarToken(null);

            Assert.Equal("*", starToken.Identifier);
        }
예제 #16
0
 private static void VerifyStarQueryTokensAreEqual(StarToken expected, StarToken actual, AssertionHandler assert)
 {
     VerifyQueryTokensAreEqual(expected.NextToken, actual.NextToken, assert);
 }
 public Expression Visit(StarToken tokenIn)
 {
     throw new NotImplementedException();
 }
 public bool Visit(StarToken tokenIn)
 {
     throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "QueryToken of type '{0}' is not supported.", tokenIn.Kind));
 }