Ejemplo n.º 1
0
        public void BackgrounderPluginTest()
        {
            var testWriterFactory = new TestWriterFactory();

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

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

                plugin.CompleteProcessing();
            }

            var expectedOutput = _testCases
                                 .Where(@case => @case.ExpectedOutput != null)
                                 .Select(@case => @case.ExpectedOutput)
                                 .ToList();
            var jobWriter = testWriterFactory.GetOneWriterAndVerifyOthersAreEmptyAndDisposed <BackgrounderJob>("BackgrounderJobs", 4);

            jobWriter.ReceivedObjects.Should().BeEquivalentTo(expectedOutput);
        }
Ejemplo n.º 2
0
        public void BadOrNoOpInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

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

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

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

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