public void Test(string delimiter, string input)
 {
     using (var reader = new StringReader(input))
     using (var scanner = new Scanner(reader))
     {
         scanner.UseDelimiter(delimiter);
         int index = 0;
         while (scanner.HasNext())
         {
             string token = scanner.Next().Trim('\n');
             if (token.Length > 0)
             {
                 string expected = string.Format(CultureInfo.InvariantCulture, "L{0}", index++);
                 Assert.IsTrue(token.StartsWith(expected, StringComparison.Ordinal), "Expected to start with '{0}' got token '{1}'", expected, token);
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        ///     Resets the reader to the start of the file
        /// </summary>
        public void ResetReader()
        {
            if (this._scanner != null)
            {
                this._scanner.Close();
            }

            this._scanner = new Scanner(this._dataFile.InputStream, this._charset);

            this._scanner.UseDelimiter(this._endOfLineTag);
            this._filePosition = 0;
            if (this._startIndex > 0)
            {
                while (this._filePosition != this._startIndex)
                {
                    this.MoveNext();
                }
            }
        }