示例#1
0
 public void ReadEmptyTestFile()
 {
     using (var stream = TestLogFiles.OpenEmptyTestFile())
     {
         var reader  = new NativeJsonLogsReader(stream, null, null);
         var results = reader.ReadLines().ToList();
         results.Should().Equal(new List <ReadLogLineResult>());
     }
 }
示例#2
0
        public void ReadTestFileWithPlainLines()
        {
            var expectedResults = new List <ReadLogLineResult>();

            for (var i = 1; i <= 6; ++i)
            {
                expectedResults.Add(new ReadLogLineResult(i, null));
            }

            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);

            using (var stream = TestLogFiles.OpenTestFileWithPlainLines())
            {
                var reader  = new NativeJsonLogsReader(stream, "testFile.txt", processingNotificationsCollector);
                var results = reader.ReadLines().ToList();
                results.Should().BeEquivalentTo(expectedResults);
            }

            processingNotificationsCollector.TotalErrorsReported.Should().Be(6);
        }
示例#3
0
        public void VerifyDifferentJsonStrings()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);

            using (var stream = TestLogFiles.OpenTestFileWithJsonData())
            {
                var reader  = new NativeJsonLogsReader(stream, "testFile.txt", processingNotificationsCollector);
                var results = reader.ReadLines().ToList();
                results.Should().BeEquivalentTo(ExpectedResults);

                // This extra steps are needed to confirm JToken equality (BeEquivalentTo above cannot do it)
                var actualPayload   = ExtractPayloadAsStrings(results);
                var expectedPayload = ExtractPayloadAsStrings(ExpectedResults);
                actualPayload.Should().BeEquivalentTo(expectedPayload);

                var actualArtData   = ExtractArtDataAsStrings(results);
                var expectedArtData = ExtractArtDataAsStrings(ExpectedResults);
                actualArtData.Should().BeEquivalentTo(expectedArtData);
            }

            processingNotificationsCollector.TotalErrorsReported.Should().Be(3);
        }