public void TestWithDifferentMaxLimitConfigured(bool useConfig, int?maxLength) { var config = useConfig ? CreateConfig(maxLength) : null; var testWriterFactory = new TestWriterFactory(); using (var plugin = new VizqlDesktopPlugin()) { plugin.Configure(testWriterFactory, config, null, new NullLoggerFactory()); foreach (var testCase in _testCases) { var logLine = testCase.GetLogLine(); plugin.ProcessLogLine(logLine, LogType.VizqlDesktop); } plugin.CompleteProcessing(); } testWriterFactory.AssertAllWritersDisposedState(true); var expectedSessions = GetExpectedOutputForName("session"); var sessionsWriter = testWriterFactory.GetWriterByName <VizqlDesktopSession>("VizqlDesktopSessions"); sessionsWriter.ReceivedObjects.Should().BeEquivalentTo(expectedSessions); var expectedErrors = GetExpectedOutputForName("error"); var errorsWriter = testWriterFactory.GetWriterByName <VizqlDesktopErrorEvent>("VizqlDesktopErrorEvents"); errorsWriter.ReceivedObjects.Should().BeEquivalentTo(expectedErrors); var expectedEndQueryEvents = GetExpectedOutputForName("endQuery"); if (useConfig && maxLength != null) { expectedEndQueryEvents = TruncateQueryText(expectedEndQueryEvents, maxLength.Value); } var endQueryEventsWriter = testWriterFactory.GetWriterByName <VizqlEndQueryEvent>("VizqlDesktopEndQueryEvents"); endQueryEventsWriter.ReceivedObjects.Should().BeEquivalentTo(expectedEndQueryEvents); var expectedPerformanceEvents = GetExpectedOutputForName("performance"); var extraEvent = GetPerformanceEvent(8.985, "end-query", 126, @"{""cols"":1,""elapsed"":8.985,""is-command"":false,""protocol-class"":""postgres"",""protocol-id"":44,""query-category"":""Data"",""query-hash"":3535682211,""query-trunc"":""SELECT * FROM very_long_table_name_so_we_have_something_to_truncate;"",""rows"":3}"); expectedPerformanceEvents.Insert(0, extraEvent); var performanceEventsWriter = testWriterFactory.GetWriterByName <VizqlPerformanceEvent>("VizqlDesktopPerformanceEvents"); performanceEventsWriter.ReceivedObjects.Should().BeEquivalentTo(expectedPerformanceEvents); }
private static void AssertLoadAllResults(TestWriterFactory testWriterFactory, PluginManager pluginManager, WritersStatistics writersStatistics) { // As number of plugins can chance over time, we're simply verifying that two known plugins are loaded correctly var loadedPlugins = pluginManager.GetPlugins(); loadedPlugins.Count().Should().BeGreaterThan(1); loadedPlugins.FirstOrDefault(plugin => plugin.Name == "Apache").Should().NotBe(null); loadedPlugins.FirstOrDefault(plugin => plugin.Name == "Filestore").Should().NotBe(null); testWriterFactory.Writers.Count.Should().BeGreaterThan(1); testWriterFactory.AssertAllWritersDisposedState(false); writersStatistics.DataSets.Should().ContainKey(new DataSetInfo("Apache", "ApacheRequests")); writersStatistics.DataSets.Should().ContainKey(new DataSetInfo("Filestore", "Filestore")); }