Beispiel #1
0
        public void TestFollowTail2()
        {
            _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            _control.LogSource = _logSource;
            DispatcherExtensions.ExecuteAllEvents();

            var entries = new List <IReadOnlyLogEntry>();

            for (int i = 0; i < 51; ++i)
            {
                entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object>
                {
                    { Columns.RawContent, "Foobar" },
                    { Columns.LogLevel, LevelFlags.Info }
                }));
            }
            _logSource.AddRange(entries);

            Thread.Sleep((int)(2 * LogEntryListView.MaximumRefreshInterval.TotalMilliseconds));
            DispatcherExtensions.ExecuteAllEvents();


            _control.FollowTail = true;
            _logSource.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object>
            {
                { Columns.RawContent, "Foobar" },
                { Columns.LogLevel, LevelFlags.Info }
            }));
            _control.OnLogFileModified(_logSource, LogSourceModification.Appended(0, _logSource.Count));
            Thread.Sleep((int)(2 * LogEntryListView.MaximumRefreshInterval.TotalMilliseconds));
            DispatcherExtensions.ExecuteAllEvents();

            _control.VerticalScrollBar.Maximum.Should().Be(15, "Because the view is missing 15 pixels to fully display the last row");
            _control.VerticalScrollBar.Value.Should().Be(15, "Because the vertical scrollbar should've moved in order to bring the last line *fully* into view");
        }
Beispiel #2
0
        private MainWindow CreateControl()
        {
            var control = new MainWindow(_applicationSettings.Object, _viewModel.Object);

            DispatcherExtensions.ExecuteAllEvents();
            return(control);
        }
Beispiel #3
0
        public void TestLogFileAdd1()
        {
            _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            _control.LogSource = _logSource;
            DispatcherExtensions.ExecuteAllEvents();

            var entries = new List <IReadOnlyLogEntry>();

            for (int i = 0; i < 1000; ++i)
            {
                entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object>
                {
                    { Columns.RawContent, "Foobar" },
                    { Columns.LogLevel, LevelFlags.Info }
                }));
            }
            _logSource.AddRange(entries);

            _control.VisibleTextLines.Count.Should().Be(0, "Because the view may not have synchronized itself with the log file");
            _control.PendingModificationsCount.Should().BeGreaterOrEqualTo(1, "Because this log file modification should have been tracked by the control");

            Thread.Sleep((int)(2 * LogEntryListView.MaximumRefreshInterval.TotalMilliseconds));
            DispatcherExtensions.ExecuteAllEvents();

            _control.VisibleTextLines.Count.Should().Be(52, "Because the view must have synchronized itself and display the maximum of 52 lines");
        }
Beispiel #4
0
        public void TestSetLogFile4()
        {
            const int lineCount = 53;

            for (int i = 0; i < lineCount; ++i)
            {
                _logSource.AddEntry("Foobar", LevelFlags.Debug);
            }

            new Action(() => _control.LogSource = _logSource).Should().NotThrow();

            // It takes some "time" until the control has done its layouting
            DispatcherExtensions.ExecuteAllEvents();

            _control.VisibleTextLines.Count.Should().Be(52, "Because the view can display 48 of the 49 lines that we've added");
            for (int i = 0; i < 52; ++i)
            {
                _control.VisibleTextLines[i].LogEntry.RawContent.Should().Be(_logSource[i].RawContent);
                _control.VisibleTextLines[i].LogEntry.LogLevel.Should().Be(_logSource[i].LogLevel);
            }

            _control.VerticalScrollBar.Minimum.Should().Be(0, "Because a scrollviewer should always start at 0");
            _control.VerticalScrollBar.Maximum.Should().Be(30, "Because we've added a total of 53 lines, of which the view can display 52 partially, and thus 30 pixels are missing in height");
            _control.VerticalScrollBar.Value.Should().Be(0);
            _control.VerticalScrollBar.ViewportSize.Should().Be(768, "Because the viewport shall be as big as the control");
        }
Beispiel #5
0
        public void TestSetLogFile1()
        {
            new Action(() => _control.LogSource = _logSource).Should().NotThrow();
            _control.LogSource.Should().BeSameAs(_logSource);

            DispatcherExtensions.ExecuteAllEvents();

            _control.VerticalScrollBar.Minimum.Should().Be(0, "Because a scrollviewer should always start at 0");
            _control.VerticalScrollBar.Maximum.Should().Be(0, "Because the log file is empty and thus no scrolling shall happen");
            _control.VerticalScrollBar.Value.Should().Be(0, "Because the log file is empty and thus no scrolling shall happen");
            _control.VerticalScrollBar.ViewportSize.Should().Be(768, "Because the viewport shall be as big as the control");
        }
Beispiel #6
0
        public void SetUp()
        {
            _mouse    = new TestMouse();
            _keyboard = new TestKeyboard();
            _columns  = Columns.Minimum.Concat(new[] { PageBufferedLogSource.RetrievalState }).ToList();

            _control = new TextCanvas(new ScrollBar(), new ScrollBar(), TextSettings.Default)
            {
                Width  = 800,
                Height = 600
            };
            _control.Arrange(new Rect(0, 0, 800, 600));
            _control.ChangeTextSettings(new TextSettings(), new TextBrushes(null));
            DispatcherExtensions.ExecuteAllEvents();
        }
Beispiel #7
0
        public void TestSetLogFile2()
        {
            _logSource.AddEntry("Foobar", LevelFlags.Debug);

            new Action(() => _control.LogSource = _logSource).Should().NotThrow();

            _control.VisibleTextLines.Count.Should().Be(1, "Because the log file contains one log line");
            _control.VisibleTextLines[0].LogEntry.RawContent.Should().Be(_logSource[0].RawContent);
            _control.VisibleTextLines[0].LogEntry.LogLevel.Should().Be(_logSource[0].LogLevel);

            DispatcherExtensions.ExecuteAllEvents();

            _control.VerticalScrollBar.Minimum.Should().Be(0, "Because a scrollviewer should always start at 0");
            _control.VerticalScrollBar.Maximum.Should().Be(0, "Because the single line that is being displayed is less than the total of 48 that can be, hence no scrolling may be allowed");
            _control.VerticalScrollBar.Value.Should().Be(0, "Because there is less content than can be displayed and thus no scrolling is necessary");
            _control.VerticalScrollBar.ViewportSize.Should().Be(768, "Because the viewport shall be as big as the control");
        }
        public void SetUp()
        {
            _settings   = new Mock <IApplicationSettings>();
            _dataSource =
                CreateViewModel(
                    new FileDataSource(_logSourceFactory, _scheduler, new DataSource("Foobar")
            {
                Id = DataSourceId.CreateNew()
            }));
            _control = new LogViewerControl
            {
                DataSource = _dataSource,
                Width      = 1024,
                Height     = 768
            };

            DispatcherExtensions.ExecuteAllEvents();
        }
Beispiel #9
0
        public void SetUp()
        {
            _keyboard = new TestKeyboard();
            _mouse    = new TestMouse();

            _control = new LogEntryListView
            {
                Width  = 1024,
                Height = 768
            };
            var availableSize = new Size(1024, 768);

            _control.Measure(availableSize);
            _control.Arrange(new Rect(new Point(), availableSize));
            DispatcherExtensions.ExecuteAllEvents();


            _logSource = new InMemoryLogSource(Columns.Minimum.Concat(new[] { PageBufferedLogSource.RetrievalState }));

            _deltaTimesColumn = (DeltaTimeColumnPresenter)typeof(LogEntryListView).GetField("_deltaTimesColumn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_control);
        }
Beispiel #10
0
        public void TestSetLogFile3()
        {
            for (int i = 0; i < 46; ++i)
            {
                _logSource.AddEntry("Foobar", LevelFlags.Debug);
            }

            new Action(() => _control.LogSource = _logSource).Should().NotThrow();

            _control.VisibleTextLines.Count.Should().Be(46, "Because the view can display 46 lines and we've added as many");
            for (int i = 0; i < 46; ++i)
            {
                _control.VisibleTextLines[i].LogEntry.RawContent.Should().Be(_logSource[i].RawContent);
                _control.VisibleTextLines[i].LogEntry.LogLevel.Should().Be(_logSource[i].LogLevel);
            }

            DispatcherExtensions.ExecuteAllEvents();

            _control.VerticalScrollBar.Minimum.Should().Be(0, "Because a scrollviewer should always start at 0");
            _control.VerticalScrollBar.Maximum.Should().Be(0, "Because we've added a total of 46 lines, which the view can display, and thus no scrolling should be necessary");
            _control.VerticalScrollBar.Value.Should().Be(0, "Because we've added a total of 46 lines, which the view can display, and thus no scrolling should be necessary");
            _control.VerticalScrollBar.ViewportSize.Should().Be(768, "Because the viewport shall be as big as the control minus the horizontal scrollbar");
        }