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"); }
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"); }
public void TestLoadUnload() { var dispatcher = Dispatcher.CurrentDispatcher; dispatcher.GetActiveDispatcherTimers().Should().BeEmpty("because the first timer should be started when the control is loaded, NOT before"); _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); dispatcher.GetActiveDispatcherTimers().Should().HaveCount(1); _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent)); dispatcher.GetActiveDispatcherTimers().Should().BeEmpty(); _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); dispatcher.GetActiveDispatcherTimers().Should().HaveCount(1); _control.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent)); dispatcher.GetActiveDispatcherTimers().Should().BeEmpty(); }