Exemple #1
0
        public void BadOrNoOpInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

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

                var wrongContentFormat = new LogLine(new ReadLogLineResult(123, "Art doesn't expect string"), TestLogFileInfo);
                var nullContent        = new LogLine(new ReadLogLineResult(123, null), TestLogFileInfo);
                var payloadIsNull      = new LogLine(new ReadLogLineResult(123, new NativeJsonLogsBaseEvent {
                    EventType = "msg", ArtData = null
                }), TestLogFileInfo);
                var incorrectArtPayload = new LogLine(new ReadLogLineResult(123, new NativeJsonLogsBaseEvent {
                    EventType = "msg", ArtData = JToken.FromObject("JSON was expected here")
                }), TestLogFileInfo);

                plugin.ProcessLogLine(wrongContentFormat, LogType.VizqlserverCpp);
                plugin.ProcessLogLine(nullContent, LogType.VizqlserverCpp);
                plugin.ProcessLogLine(payloadIsNull, LogType.VizqlserverCpp);
                plugin.ProcessLogLine(incorrectArtPayload, LogType.VizqlserverCpp);
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(2);
            processingNotificationsCollector.TotalErrorsReported.Should().Be(3);
        }
Exemple #2
0
        public void SpecialCase_CompletelyIncompatibleJsonInArtData()
        {
            var testWriterFactory = new TestWriterFactory();

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

                var incorrectJsonInArtPayload = new LogLine(new ReadLogLineResult(123, new NativeJsonLogsBaseEvent {
                    EventType = "msg", ArtData = JToken.FromObject(new { SomeOtherKey = "test" })
                }), TestLogFileInfo);
                plugin.ProcessLogLine(incorrectJsonInArtPayload, LogType.VizqlserverCpp);
            }

            var testWriter = testWriterFactory.GetOneWriterAndVerifyOthersAreEmptyAndDisposed <FlattenedArtEvent>("Art", 2);

            testWriter.ReceivedObjects.Count.Should().Be(1);
            testWriter.ReceivedObjects.First().Should().NotBeNull(); // All props are null, but object still exists
        }
Exemple #3
0
        public void RunTestCases(LogType logTypeToUse, string expectedNonEmptyWriterName)
        {
            var testWriterFactory = new TestWriterFactory();

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

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

            var expectedOutput = _testCases.Select(testCase => testCase.ExpectedOutput).ToList();

            testWriterFactory.Writers.Count.Should().Be(2);

            var testWriter = testWriterFactory.GetOneWriterAndVerifyOthersAreEmptyAndDisposed <FlattenedArtEvent>(expectedNonEmptyWriterName, 2);

            testWriter.WasDisposed.Should().Be(true);
            testWriter.ReceivedObjects.Should().BeEquivalentTo(expectedOutput);
        }