public void TestCurrentLineChanged6()
        {
            var notifier = new LogFileListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromHours(1), 1000);

            notifier.OnRead(-1);
            _changes.Should().Equal(new[]
            {
                LogFileSection.Reset
            });
        }
        public void TestInvalidate5()
        {
            var notifier = new LogFileListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromMilliseconds(100), 100);

            notifier.OnRead(1);
            notifier.OnRead(-1);
            _changes.Should().Equal(new[] { LogFileSection.Reset });
            notifier.OnRead(-1);
            _changes.Should().Equal(new[] { LogFileSection.Reset });
            notifier.OnRead(-1);
            _changes.Should().Equal(new[] { LogFileSection.Reset });
        }
        public void TestInvalidate1()
        {
            var notifier = new LogFileListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.Zero, 1);

            notifier.OnRead(1);
            notifier.Invalidate(0, 1);
            _changes.Should().Equal(new[]
            {
                LogFileSection.Reset,
                new LogFileSection(0, 1),
                LogFileSection.Invalidate(0, 1)
            });
            notifier.LastNumberOfLines.Should().Be(0);
        }
        public void TestInvalidate2()
        {
            var notifier = new LogFileListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromSeconds(1), 10);

            notifier.OnRead(10);
            notifier.OnRead(12);
            notifier.Invalidate(0, 12);
            _changes.Should().Equal(new[]
            {
                LogFileSection.Reset,
                new LogFileSection(0, 10),
                LogFileSection.Invalidate(0, 10)
            },
                                    "Because the notifier should've reported only the first 10 changes and therefore Invalidate() only had to invalidate those 10 changes"
                                    );
            notifier.LastNumberOfLines.Should().Be(0);
        }
        public void TestCurrentLineChanged1()
        {
            var notifier = new LogFileListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.Zero, 1);

            notifier.OnRead(1);
            notifier.OnRead(2);
            notifier.OnRead(3);
            notifier.OnRead(4);

            _changes.Should().Equal(new[]
            {
                LogFileSection.Reset,
                new LogFileSection(0, 1),
                new LogFileSection(1, 1),
                new LogFileSection(2, 1),
                new LogFileSection(3, 1)
            });
        }
        public void TestCurrentLineChanged2()
        {
            var notifier = new LogFileListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromHours(1), 4);

            _changes.Clear();

            notifier.OnRead(1);
            _changes.Should().BeEmpty();
            notifier.OnRead(2);
            _changes.Should().BeEmpty();
            notifier.OnRead(3);
            _changes.Should().BeEmpty();

            notifier.OnRead(4);
            _changes.Should().Equal(new[]
            {
                new LogFileSection(0, 4)
            });
        }
        public void TestInvalidate4()
        {
            var notifier = new LogFileListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromMilliseconds(100), 100);

            notifier.OnRead(9);
            Thread.Sleep(TimeSpan.FromMilliseconds(1000));
            notifier.OnRead(9);
            _changes.Should().Equal(new[]
            {
                LogFileSection.Reset,
                new LogFileSection(0, 9)
            });

            notifier.OnRead(35);
            notifier.Invalidate(10, 25);
            _changes.Should().Equal(new[]
            {
                LogFileSection.Reset,
                new LogFileSection(0, 9)
            },
                                    "Because the notifier should've reported only the first 10 changes and therefore Invalidate() only had to invalidate those 10 changes"
                                    );
            notifier.LastNumberOfLines.Should().Be(9);
        }