예제 #1
0
        public void Setup()
        {
            _logFile = new Mock<ILogFile>();
            _listeners = new LogFileListenerCollection(_logFile.Object);
            _logFile.Setup(x => x.AddListener(It.IsAny<ILogFileListener>(), It.IsAny<TimeSpan>(), It.IsAny<int>()))
                    .Callback((ILogFileListener listener, TimeSpan maximumWaitTime, int maximumLineCount) => _listeners.AddListener(listener, maximumWaitTime, maximumLineCount));
            _logFile.Setup(x => x.RemoveListener(It.IsAny<ILogFileListener>()))
                    .Callback((ILogFileListener listener) => _listeners.RemoveListener(listener));

            _listener = new Mock<ILogFileListener>();
            _modifications = new List<LogFileSection>();
            _listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
                     .Callback((ILogFile logFile, LogFileSection section) => _modifications.Add(section));
        }
 public void Setup()
 {
     _entries = new List<LogLine>();
     _logFile = new Mock<ILogFile>();
     _listeners = new LogFileListenerCollection(_logFile.Object);
     _logFile.Setup(x => x.EndOfSourceReached).Returns(true);
     _logFile.Setup(x => x.GetSection(It.IsAny<LogFileSection>(), It.IsAny<LogLine[]>()))
             .Callback(
                 (LogFileSection section, LogLine[] entries) =>
                 _entries.CopyTo((int)section.Index, entries, 0, section.Count));
     _logFile.Setup(x => x.AddListener(It.IsAny<ILogFileListener>(), It.IsAny<TimeSpan>(), It.IsAny<int>()))
             .Callback((ILogFileListener listener, TimeSpan maximumWaitTime, int maximumLineCount) => _listeners.AddListener(listener, maximumWaitTime, maximumLineCount));
     _logFile.Setup(x => x.RemoveListener(It.IsAny<ILogFileListener>()))
             .Callback((ILogFileListener listener) => _listeners.RemoveListener(listener));
     _logFile.Setup(x => x.GetLine(It.IsAny<int>())).Returns((int index) => _entries[index]);
     _logFile.Setup(x => x.Count).Returns(() => _entries.Count);
 }