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 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); }