Пример #1
0
        public void StreamAccess_WithMultipleIndices_EnumeratesSourceAtMostOnce(IEnumerable <int> accessIndices, IEnumerable <string?> expectedTokens)
        {
            var source   = new TokenSource();
            var stream   = new TokenStream(new StaticLexer(source.GetTokens()));
            var tokens   = new List <string?>();
            var maxIndex = 0;

            foreach (var i in accessIndices)
            {
                tokens.Add(stream.Get(i).Value);
                maxIndex = Math.Max(maxIndex, i);
            }

            source.EnumerationCount.Should().Be(1);
            source.MaxStep.Should().Be(maxIndex + 1);
            tokens.Should().BeEquivalentTo(expectedTokens);
        }