Exemplo n.º 1
0
        public void TestSetLogFile4()
        {
            const int lineCount = 53;

            for (int i = 0; i < lineCount; ++i)
            {
                _lines.Add(new LogLine(0, 0, "Foobar", LevelFlags.Debug));
            }

            new Action(() => _control.LogFile = _logFile.Object).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].LogLine.Should().Be(_lines[i]);
            }

            _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");
        }
Exemplo n.º 2
0
        public void TestSetLogFile1()
        {
            new Action(() => _control.LogFile = _logFile.Object).Should().NotThrow();
            _control.LogFile.Should().BeSameAs(_logFile.Object);

            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");
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            _mouse    = new TestMouse();
            _keyboard = new TestKeyboard();

            _control = new TextCanvas(new ScrollBar(), new ScrollBar(), TextSettings.Default)
            {
                Width  = 800,
                Height = 600
            };
            _control.Arrange(new Rect(0, 0, 800, 600));
            DispatcherExtensions.ExecuteAllEvents();
        }
Exemplo n.º 4
0
        public void TestSetLogFile2()
        {
            _lines.Add(new LogLine(0, 0, "Foobar", LevelFlags.Debug));

            new Action(() => _control.LogFile = _logFile.Object).Should().NotThrow();

            _control.VisibleTextLines.Count.Should().Be(1, "Because the log file contains one log line");
            _control.VisibleTextLines[0].LogLine.Should().Be(_lines[0]);

            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");
        }
Exemplo n.º 5
0
        public void SetUp()
        {
            _settings   = new Mock <IApplicationSettings>();
            _dataSource =
                new SingleDataSourceViewModel(
                    new SingleDataSource(_logFileFactory, _scheduler, new DataSource("Foobar")
            {
                Id = DataSourceId.CreateNew()
            }),
                    _actionCenter.Object);
            _control = new LogViewerControl
            {
                DataSource = _dataSource,
                Width      = 1024,
                Height     = 768
            };

            DispatcherExtensions.ExecuteAllEvents();
        }
Exemplo n.º 6
0
        public void TestLogFileAdd1()
        {
            _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            _control.LogFile = _logFile.Object;
            DispatcherExtensions.ExecuteAllEvents();

            for (int i = 0; i < 1000; ++i)
            {
                _lines.Add(new LogLine(i, i, "Foobar", LevelFlags.Info));
            }
            _listeners[0].OnLogFileModified(_logFile.Object, new LogFileSection(0, _lines.Count));

            _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");
        }
Exemplo n.º 7
0
        public void TestFollowTail1()
        {
            _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            _control.LogFile = _logFile.Object;
            DispatcherExtensions.ExecuteAllEvents();

            for (int i = 0; i < 52; ++i)
            {
                _lines.Add(new LogLine(i, i, "Foobar", LevelFlags.Info));
            }
            _listeners[0].OnLogFileModified(_logFile.Object, new LogFileSection(0, _lines.Count));

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

            _control.VerticalScrollBar.Value.Should().Be(0);
            _control.VisibleTextLines.Count.Should().Be(52);

            _control.FollowTail = true;
            _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");
        }
Exemplo n.º 8
0
        public void TestSetLogFile3()
        {
            for (int i = 0; i < 46; ++i)
            {
                _lines.Add(new LogLine(0, 0, "Foobar", LevelFlags.Debug));
            }

            new Action(() => _control.LogFile = _logFile.Object).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].LogLine.Should().Be(_lines[i]);
            }

            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");
        }
Exemplo n.º 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();

            _lines     = new List <LogLine>();
            _listeners = new List <ILogFileListener>();

            _logFile = new Mock <ILogFile>();
            _logFile.Setup(x => x.Count).Returns(() => _lines.Count);
            _logFile.Setup(x => x.GetSection(It.IsAny <LogFileSection>(), It.IsAny <LogLine[]>()))
            .Callback((LogFileSection section, LogLine[] dest) =>
                      _lines.CopyTo((int)section.Index, dest, 0, section.Count));
            _logFile.Setup(x => x.GetLine(It.IsAny <int>())).Returns((int index) =>
                                                                     _lines[index]);
            _logFile.Setup(x => x.AddListener(It.IsAny <ILogFileListener>(), It.IsAny <TimeSpan>(), It.IsAny <int>()))
            .Callback((ILogFileListener listener, TimeSpan maximumTimeout, int maximumLines) =>
            {
                _listeners.Add(listener);
                listener.OnLogFileModified(_logFile.Object,
                                           new LogFileSection(0, _lines.Count));
            });

            _deltaTimesColumn = (DeltaTimeColumnPresenter)typeof(LogEntryListView).GetField("_deltaTimesColumn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_control);
        }