public void TestListen1() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.FromSeconds(1), 1000); proxy.OnLogFileModified(_logFile.Object, new LogFileSection(0, 1)); _modifications.Property(x => x.Count).ShouldEventually().Be(2); _modifications.Should().Equal(new[] { LogFileSection.Reset, new LogFileSection(0, 1) }); } }
public void TestListen4() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000); new Action(() => proxy.OnLogFileModified(new Mock<ILogFile>().Object, new LogFileSection(0, 1))).ShouldNotThrow(); _modifications.Should().Equal(new[] { LogFileSection.Reset }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source"); new Action(() => proxy.OnLogFileModified(null, new LogFileSection(0, 1))).ShouldNotThrow(); _modifications.Should().Equal(new[] { LogFileSection.Reset }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source"); } }
public void TestListen3() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000); _listeners.OnRead(500); _listeners.Invalidate(400, 100); _listeners.OnRead(550); _scheduler.RunOnce(); _modifications.Should().Equal(new[] { LogFileSection.Reset, new LogFileSection(0, 500), new LogFileSection(400, 100, true), new LogFileSection(400, 150) }); } }