示例#1
0
        public void LowerLevelDefinedDoesNotWriteToPipeline()
        {
            var healthReportMock  = new Mock <IHealthReporter>();
            var configurationMock = new Log4netConfiguration {
                Log4netLevel = Level.Info
            };
            var mockOutput = new Mock <IOutput>();

            using (var log4NetInput = new Log4netInput(configurationMock, healthReportMock.Object))
                using (var pipeline = new DiagnosticPipeline(
                           healthReportMock.Object,
                           new[] { log4NetInput },
                           new IFilter[0],
                           new[] { new EventSink(mockOutput.Object, new IFilter[0]) }))
                {
                    var logger = LogManager.GetLogger("EventFlowRepo", typeof(Log4NetInputTests));
                    logger.Debug("some message");
                }
            mockOutput.Verify(
                output => output.SendEventsAsync(It.IsAny <IReadOnlyCollection <EventData> >(), It.IsAny <long>(), It.IsAny <CancellationToken>()),
                Times.Never);
        }
示例#2
0
        public void ValidConfigurationCanWrtieToInputPipleine()
        {
            var healthReportMock  = new Mock <IHealthReporter>();
            var configurationMock = new Log4netConfiguration {
                LogLevel = "INFO"
            };
            var mockOutput = new Mock <IOutput>();

            using (var log4NetInput = new Log4netInput(configurationMock, healthReportMock.Object))
                using (var pipeline = new DiagnosticPipeline(
                           healthReportMock.Object,
                           new[] { log4NetInput },
                           new IFilter[0],
                           new[] { new EventSink(mockOutput.Object, new IFilter[0]) }))
                {
                    var logger = LogManager.GetLogger("EventFlowRepo", typeof(Log4NetInputTests));
                    logger.Info("some message");
                }
            mockOutput.Verify(
                output => output.SendEventsAsync(It.Is <IReadOnlyCollection <EventData> >(c => c.Count == 1),
                                                 It.IsAny <long>(), It.IsAny <CancellationToken>()), Times.Exactly(1));
        }