Example #1
0
 /// <summary>
 /// Instantiates a new <see cref="Enumerator"/> instance for <paramref name="tokenizer"/>.
 /// </summary>
 /// <param name="tokenizer">The containing <see cref="TrimmingTokenizer"/>.</param>
 public Enumerator(TrimmingTokenizer tokenizer)
 {
     _tokenizer  = tokenizer;
     _count      = 0;
     _enumerator = tokenizer._tokenizer.GetEnumerator();
     _remainder  = StringSegment.Empty;
 }
Example #2
0
        public void Count_ReturnsExpectedValue_WithMaxCount(int maxCount, int expetedCount)
        {
            // Arrange
            var tokenizer = new TrimmingTokenizer(" , , , a, , , , b, c, , , ", new[] { ' ' }, maxCount);

            // Act
            var actual = tokenizer.Count;

            // Assert
            Assert.Equal(expetedCount, actual);
        }
Example #3
0
        public void StringEnumerator_ReturnsExpectedValues(string value, char[] separators, StringSegment[] expected)
        {
            // Arrange
            var tokenizer = new TrimmingTokenizer(value, separators);

            // Act
            var actual = tokenizer.ToArray();

            // Assert
            Assert.Equal(expected, actual);
        }
Example #4
0
        public void Count_ReturnsExpectedValue_WithMaxCount2(string value, char[] separators, int expected)
        {
            // Arrange
            var tokenizer = new TrimmingTokenizer(value, separators, maxCount: 2);

            // Act
            var actual = tokenizer.Count;

            // Assert
            Assert.Equal(expected, actual);
        }
Example #5
0
        public void SegmentEnumerator_ReturnsExpectedValues_WithMaxCount2(
            string value,
            char[] separators,
            StringSegment[] expected)
        {
            // Arrange
            var segment   = (StringSegment)value;
            var tokenizer = new TrimmingTokenizer(segment, separators, maxCount: 2);

            // Act
            var actual = tokenizer.ToArray();

            // Assert
            Assert.Equal(expected, actual);
        }