public void TestFlush2() { var collection = new LogFileListenerCollection(new Mock<ILogFile>().Object); var listener = new Mock<ILogFileListener>(); var sections = new List<LogFileSection>(); listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>())) .Callback((ILogFile file, LogFileSection y) => sections.Add(y)); collection.AddListener(listener.Object, TimeSpan.FromHours(1), 1000); collection.OnRead(1); collection.Flush(); collection.Flush(); sections.Should().Equal(new object[] { LogFileSection.Reset, new LogFileSection(0, 1) }, "Because Flush() shouldn't forward the same result to the same listener more than once"); }
public void TestFlush3() { var collection = new LogFileListenerCollection(new Mock<ILogFile>().Object); var listener = new Mock<ILogFileListener>(); var sections = new List<LogFileSection>(); listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>())) .Callback((ILogFile file, LogFileSection y) => sections.Add(y)); collection.AddListener(listener.Object, TimeSpan.FromHours(1), 1000); collection.OnRead(1); collection.Flush(); collection.OnRead(2); collection.Flush(); sections.Should().Equal(new object[] { LogFileSection.Reset, new LogFileSection(0, 1), new LogFileSection(1, 1) }); }