示例#1
0
        public void TestDispose1()
        {
            var             filter = new EmptyLogLineFilter();
            FilteredLogFile file   = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, _logFile.Object, filter, null);

            _logFile.Verify(x => x.AddListener(It.Is <ILogFileListener>(y => Equals(y, file)),
                                               It.IsAny <TimeSpan>(),
                                               It.IsAny <int>()), Times.Once, "because the filtered log file should register itself as a listener with its source");

            new Action(() => file.Dispose()).Should().NotThrow("because Dispose() must always succeed");

            _logFile.Verify(x => x.RemoveListener(It.Is <ILogFileListener>(y => Equals(y, file))), Times.Once,
                            "because the filtered log file should unregister itself as a listener from its source when being disposed of");
        }