コード例 #1
0
        public void TestInvalidate5()
        {
            var notifier = new LogSourceListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromMilliseconds(100), 100);

            notifier.OnRead(1);
            notifier.OnRead(-1);
            _modifications.Should().Equal(new[] { LogSourceModification.Reset() });
            notifier.OnRead(-1);
            _modifications.Should().Equal(new[] { LogSourceModification.Reset() });
            notifier.OnRead(-1);
            _modifications.Should().Equal(new[] { LogSourceModification.Reset() });
        }
コード例 #2
0
        public void TestInvalidate2()
        {
            var notifier = new LogSourceListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromSeconds(1), 10);

            notifier.OnRead(10);
            notifier.OnRead(12);
            notifier.Remove(0, 12);
            _modifications.Should().Equal(new[]
            {
                LogSourceModification.Reset(),
                LogSourceModification.Appended(0, 10),
                LogSourceModification.Removed(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);
        }
コード例 #3
0
        public void TestCurrentLineChanged4()
        {
            var notifier = new LogSourceListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromHours(1), 1000);

            notifier.OnRead(1000);
            _modifications.Should().Equal(new[]
            {
                LogSourceModification.Reset(),
                LogSourceModification.Appended(0, 1000)
            });
            notifier.OnRead(2000);
            _modifications.Should().Equal(new[]
            {
                LogSourceModification.Reset(),
                LogSourceModification.Appended(0, 1000),
                LogSourceModification.Appended(1000, 1000)
            });
        }
コード例 #4
0
        public void TestCurrentLineChanged1()
        {
            var notifier = new LogSourceListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.Zero, 1);

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

            _modifications.Should().Equal(new[]
            {
                LogSourceModification.Reset(),
                LogSourceModification.Appended(0, 1),
                LogSourceModification.Appended(1, 1),
                LogSourceModification.Appended(2, 1),
                LogSourceModification.Appended(3, 1)
            });
        }
コード例 #5
0
        public void TestCurrentLineChanged2()
        {
            var notifier = new LogSourceListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.FromHours(1), 4);

            _modifications.Clear();

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

            notifier.OnRead(4);
            _modifications.Should().Equal(new[]
            {
                LogSourceModification.Appended(0, 4)
            });
        }
コード例 #6
0
        public void TestInvalidate1()
        {
            var notifier = new LogSourceListenerNotifier(_logFile.Object, _listener.Object, TimeSpan.Zero, 1);

            notifier.OnRead(1);
            notifier.Remove(0, 1);
            _modifications.Should().Equal(new[]
            {
                LogSourceModification.Reset(),
                LogSourceModification.Appended(0, 1),
                LogSourceModification.Removed(0, 1)
            });
            notifier.LastNumberOfLines.Should().Be(0);
        }