コード例 #1
0
        public void TestManyEntries7()
        {
            var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero);

            logFile.AddListener(_listener.Object, TimeSpan.Zero, 3);

            _lines.Add(new LogLine(0, 0, "A", LevelFlags.None));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1));
            _taskScheduler.RunOnce();

            _lines.Add(new LogLine(1, 1, "B", LevelFlags.Info));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(1, 1));
            _taskScheduler.RunOnce();

            _lines[1] = new LogLine(1, 1, "B", LevelFlags.None);
            _lines.Add(new LogLine(2, 2, "C", LevelFlags.None));
            logFile.OnLogFileModified(_source.Object, LogFileSection.Invalidate(1, 1));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(1, 2));
            _taskScheduler.RunOnce();

            logFile.GetSection(new LogFileSection(0, 3))
            .Should().Equal(
                new LogLine(0, 0, "A", LevelFlags.None),
                new LogLine(1, 1, "B", LevelFlags.None),
                new LogLine(2, 2, "C", LevelFlags.None));
        }
コード例 #2
0
        public void TestTwoEntries1()
        {
            var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero);

            _lines.Add(new LogLine(0, 0, "DEBUG: Starting...", LevelFlags.Debug));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1));
            _taskScheduler.RunOnce();

            logFile.AddListener(_listener.Object, TimeSpan.Zero, 10);
            _lines.Add(new LogLine(1, 1, "INFO: hello", LevelFlags.Info));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(1, 1));
            _taskScheduler.RunOnce();
            _changes.Should().Equal(new object[]
            {
                LogFileSection.Reset,
                new LogFileSection(0, 1),
                new LogFileSection(1, 1)
            });

            _changes.Clear();
            _lines.Add(new LogLine(2, 2, "world!", LevelFlags.None));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(2, 1));
            _taskScheduler.RunOnce();
            _changes.Should().Equal(new object[]
            {
                LogFileSection.Invalidate(1, 1),
                new LogFileSection(1, 2)
            });
        }
コード例 #3
0
        public void TestOneLine2()
        {
            var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero);

            logFile.AddListener(_listener.Object, TimeSpan.Zero, 10);

            _lines.Add(new LogLine(0, 0, "INFO: Hello ", LevelFlags.Info));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1));
            _taskScheduler.RunOnce();
            logFile.Count.Should().Be(1);
            _changes.Should().Equal(new object[] { LogFileSection.Reset, new LogFileSection(0, 1) });

            _lines[0] = new LogLine(0, 0, "Hello World!", LevelFlags.None);
            logFile.OnLogFileModified(_source.Object, LogFileSection.Invalidate(0, 1));
            _taskScheduler.RunOnce();
            logFile.Count.Should().Be(0);

            logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1));
            _taskScheduler.RunOnce();
            logFile.Count.Should().Be(1);
            _changes.Should().Equal(new object[]
            {
                LogFileSection.Reset,
                new LogFileSection(0, 1),
                LogFileSection.Invalidate(0, 1),
                new LogFileSection(0, 1)
            });

            logFile.GetLine(0).Should().Be(new LogLine(0, 0, "Hello World!", LevelFlags.None));
        }
コード例 #4
0
        public void TestOneEntry3()
        {
            var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero);

            logFile.AddListener(_listener.Object, TimeSpan.Zero, 10);

            _lines.Add(new LogLine(0, 0, "INFO: hello", LevelFlags.Info));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1));
            _taskScheduler.RunOnce();
            _changes.Should().Equal(new object[] { LogFileSection.Reset, new LogFileSection(0, 1) });

            _changes.Clear();
            _lines.Add(new LogLine(1, 1, "world!", LevelFlags.Other));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(1, 1));
            _taskScheduler.RunOnce();
            _changes.Should().Equal(new object[]
            {
                new LogFileSection(1, 1)
            });
        }
コード例 #5
0
        public void TestManyEntries6()
        {
            var logFile = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero);

            logFile.AddListener(_listener.Object, TimeSpan.Zero, 3);

            _lines.Add(new LogLine(0, 0, "A", LevelFlags.Other));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(0, 1));
            _taskScheduler.RunOnce();

            _lines.Add(new LogLine(1, 1, "B", LevelFlags.Other));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(1, 1));
            _taskScheduler.RunOnce();

            _lines.Add(new LogLine(2, 2, "C", LevelFlags.Info));
            logFile.OnLogFileModified(_source.Object, new LogFileSection(2, 1));
            _taskScheduler.RunOnce();

            _changes.Should().Equal(LogFileSection.Reset,
                                    new LogFileSection(0, 1),
                                    new LogFileSection(1, 1),
                                    new LogFileSection(2, 1));
        }