public void BadInput() { var processingNotificationsCollector = new ProcessingNotificationsCollector(10); var testWriterFactory = new TestWriterFactory(); using (var plugin = new PostgresPlugin()) { 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); var stringContent = new LogLine(new ReadLogLineResult(123, "I don't expect string!"), TestLogFileInfo); plugin.ProcessLogLine(wrongContentFormat, LogType.PostgresCsv); plugin.ProcessLogLine(nullContent, LogType.PostgresCsv); plugin.ProcessLogLine(stringContent, LogType.PostgresCsv); } testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1); processingNotificationsCollector.TotalErrorsReported.Should().Be(3); }
public void RunTestCases() { var testWriterFactory = new TestWriterFactory(); using (var plugin = new PostgresPlugin()) { plugin.Configure(testWriterFactory, null, null, new NullLoggerFactory()); foreach (var testCase in _testCases) { var logLine = testCase.GetLogLine(); plugin.ProcessLogLine(logLine, LogType.PostgresCsv); } } var expectedOutput = _testCases.Select(testCase => testCase.ExpectedOutput).ToList(); var testWriter = testWriterFactory.Writers.Values.First() as TestWriter <PostgresEvent>; testWriterFactory.Writers.Count.Should().Be(1); testWriter.WasDisposed.Should().Be(true); testWriter.ReceivedObjects.Should().BeEquivalentTo(expectedOutput); }