示例#1
0
        public void RunTestCases_SkipHealthChecks()
        {
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new ApachePlugin())
            {
                plugin.Configure(testWriterFactory, _configSkippingHealthChecks.GetSection("PluginsConfiguration:ApachePlugin"), null, new NullLoggerFactory());

                foreach (var testCase in _testCases)
                {
                    var logLine = testCase.GetLogLine();
                    plugin.ProcessLogLine(logLine, LogType.Apache);
                }
            }

            var expectedOutput = _testCases
                                 .Select(testCase => testCase.ExpectedOutput)
                                 .Where(@event => ((dynamic)@event).RequestBody != "/favicon.ico")
                                 .ToList();

            testWriterFactory.Writers.Count.Should().Be(1);
            var testWriter = testWriterFactory.Writers.Values.First() as TestWriter <ApacheEvent>;

            testWriter.WasDisposed.Should().Be(true);
            testWriter.ReceivedObjects.Should().BeEquivalentTo(expectedOutput);
        }
示例#2
0
        public void BadInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new ApachePlugin())
            {
                plugin.Configure(testWriterFactory, null, processingNotificationsCollector, new NullLoggerFactory());

                var wrongContentFormat = new LogLine(new ReadLogLineResult(123, 1234), TestLogFileInfo);
                var nullContent        = new LogLine(new ReadLogLineResult(123, null), TestLogFileInfo);

                plugin.ProcessLogLine(wrongContentFormat, LogType.Apache);
                plugin.ProcessLogLine(nullContent, LogType.Apache);
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            processingNotificationsCollector.TotalErrorsReported.Should().Be(2);
        }