private static void RunDisposeTest(Action<LookaheadTextReader> triggerAction)
        {
            // Arrange
            var source = new DisposeTestMockTextReader();
            var reader = new BufferingTextReader(source);

            // Act
            triggerAction(reader);

            // Assert
            Assert.True(source.Disposed);
        }
        public void BacktrackBufferIsClearedWhenEndReachedAndNoCurrentLookaheads()
        {
            // Arrange
            var source = new StringReader(TestString);
            var reader = new BufferingTextReader(source);

            reader.Read(); // Reader: "bcdefg"
            using (reader.BeginLookahead())
            {
                reader.Read(); // Reader: "cdefg"
            } // Reader: "bcdefg"
            reader.Read(); // Reader: "cdefg"
            Assert.NotNull(reader.Buffer); // Verify our assumption that the buffer still exists

            // Act
            reader.Read();

            // Assert
            Assert.False(reader.Buffering, "The buffer was not reset when the end was reached");
            Assert.Equal(0, reader.Buffer.Length);
        }