Ejemplo n.º 1
0
        public void BadInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new NetstatPlugin())
            {
                plugin.Configure(testWriterFactory, null, processingNotificationsCollector, new NullLoggerFactory());
                var logFileInfo = new LogFileInfo("netstat-anp.txt", @"folder1/netstat-anp.txt", "worker1", new DateTime(2019, 04, 12, 13, 33, 31));

                var wrongContentFormat = new LogLine(new ReadLogLineResult(123, 1234), logFileInfo);
                var nullContent        = new LogLine(new ReadLogLineResult(123, null), logFileInfo);

                plugin.ProcessLogLine(wrongContentFormat, LogType.NetstatLinux);
                plugin.ProcessLogLine(nullContent, LogType.NetstatLinux);
                plugin.ProcessLogLine(nullContent, LogType.NetstatWindows);
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            processingNotificationsCollector.TotalErrorsReported.Should().Be(3);
        }
Ejemplo n.º 2
0
        public void NetstatPluginTest()
        {
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new NetstatPlugin())
            {
                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 <NetstatActiveConnection>;

            testWriterFactory.Writers.Count.Should().Be(1);
            testWriter.WasDisposed.Should().Be(true);
            testWriter.ReceivedObjects.Should().BeEquivalentTo(expectedOutput);
        }