public void BadInput() { var processingNotificationsCollector = new ProcessingNotificationsCollector(10); var testWriterFactory = new TestWriterFactory(); using (var plugin = new SearchServerPlugin()) { 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 incorrectContent = new LogLine(new ReadLogLineResult(123, "I am not a SearchServer line!"), TestLogFileInfo); plugin.ProcessLogLine(wrongContentFormat, LogType.SearchServer); plugin.ProcessLogLine(nullContent, LogType.SearchServer); plugin.ProcessLogLine(incorrectContent, LogType.SearchServer); } testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1); processingNotificationsCollector.TotalErrorsReported.Should().Be(3); }
public void SearchServerPluginTest() { var testWriterFactory = new TestWriterFactory(); using (var plugin = new SearchServerPlugin()) { plugin.Configure(testWriterFactory, null, null, new NullLoggerFactory()); foreach (var testCase in _testCases) { var logLine = testCase.GetLogLine(); plugin.ProcessLogLine(logLine, testCase.LogType); } } var expectedOutput = _testCases.Select(testCase => testCase.ExpectedOutput).ToList(); var testWriter = testWriterFactory.Writers.Values.First() as TestWriter <SearchServerEvent>; testWriterFactory.Writers.Count.Should().Be(1); testWriter.WasDisposed.Should().Be(true); testWriter.ReceivedObjects.Should().BeEquivalentTo(expectedOutput); }