public void TestChangeLogView4() { _control.DataSource = null; var dataSource = new Mock <IDataSource>(); var logFile = new Mock <ILogSource>(); logFile.Setup(x => x.GetProperty(Properties.LogEntryCount)).Returns(100); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(logFile.Object); var dataSourceViewModel = CreateDataSourceViewModel(); dataSourceViewModel.Setup(x => x.DataSource).Returns(dataSource.Object); dataSourceViewModel.Setup(x => x.SelectedLogLines).Returns(new HashSet <LogLineIndex> { new LogLineIndex(42) }); var searchViewModel = new Mock <ISearchViewModel>(); searchViewModel.Setup(x => x.Term).Returns("Foobar"); dataSourceViewModel.Setup(x => x.Search).Returns(searchViewModel.Object); var logView = new LogViewerViewModel(dataSourceViewModel.Object, _actionCenter.Object, _settings.Object); _control.LogView = logView; _control.SelectedIndices.Should().Equal(new LogLineIndex(42)); }
public void TestScreenCleared() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.LogEntryCount)).Returns(1); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.SearchTerm).Returns(""); dataSource.Setup(x => x.LevelFilter).Returns(LevelFlags.All); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); dataSource.Setup(x => x.ScreenCleared).Returns(true); dataSource.Setup(x => x.QuickFilterChain).Returns((IEnumerable <ILogEntryFilter>)null); var dataSourceViewModel = new Mock <IFileDataSourceViewModel>(); dataSourceViewModel.Setup(x => x.DataSource).Returns(dataSource.Object); var model = new LogViewerViewModel(dataSourceViewModel.Object, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("The screen was cleared"); model.NoEntriesAction.Should().Be("No new log entries have been added to the data source since the screen was cleared. Try waiting for a little longer or show all log entries again."); }
public void TestChangeLogView4() { _control.DataSource = null; var dataSource = new Mock <IDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.Count).Returns(100); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogFile).Returns(logFile.Object); var dataSourceViewModel = new Mock <IDataSourceViewModel>(); dataSourceViewModel.Setup(x => x.DataSource).Returns(dataSource.Object); dataSourceViewModel.Setup(x => x.SelectedLogLines).Returns(new HashSet <LogLineIndex> { new LogLineIndex(42) }); dataSourceViewModel.Setup(x => x.SearchTerm).Returns("Foobar"); var logView = new LogViewerViewModel(dataSourceViewModel.Object, _actionCenter.Object, _settings.Object); _control.SearchBox.Text.Should().Be(string.Empty); _control.LogView = logView; _control.SelectedIndices.Should().Equal(new LogLineIndex(42)); _control.SearchBox.Text.Should().Be("Foobar"); }
private void OnLogViewChanged(LogViewerViewModel oldView, LogViewerViewModel newView) { try { _changingLogView = true; if (oldView != null) { oldView.PropertyChanged -= LogViewOnPropertyChanged; } if (newView != null) { newView.PropertyChanged += LogViewOnPropertyChanged; DataSource = newView.DataSource; LogFile = newView.LogFile; Search = newView.Search; CurrentLogLine = newView.DataSource.VisibleLogLine; Select(newView.DataSource.SelectedLogLines); SetHorizontalOffset(newView.DataSource.HorizontalOffset); } else { DataSource = null; LogFile = null; } } finally { _changingLogView = false; } }
public void TestDataSourceDoesntExist2() { var dataSource = new Mock <ISingleDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.SourceDoesNotExist); logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns((Size?)null); var filteredLogFile = new Mock <ILogFile>(); ILogFileListener listener = null; filteredLogFile.Setup(x => x.AddListener(It.IsAny <ILogFileListener>(), It.IsAny <TimeSpan>(), It.IsAny <int>())) .Callback((ILogFileListener l, TimeSpan t, int i) => listener = l); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogFile).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogFileSearch>().Object); var dataSourceModel = new SingleDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Can't find \"somefile.log\""); model.NoEntriesSubtext.Should().Be("It was last seen at E:\\Tailviewer"); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.None); logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(Size.Zero); listener.OnLogFileModified(logFile.Object, new LogFileSection(0, 0)); model.Update(); model.NoEntriesExplanation.Should().Be("The data source is empty"); model.NoEntriesSubtext.Should().BeNull(); }
public void TestQuickFilter() { var dataSource = new Mock <ISingleDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.None); logFile.Setup(x => x.Count).Returns(1); logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogFile>(); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogFile).Returns(filteredLogFile.Object); dataSource.Setup(x => x.SearchTerm).Returns(""); dataSource.Setup(x => x.QuickFilterChain).Returns(new List <ILogEntryFilter> { new Mock <ILogEntryFilter>().Object }); dataSource.Setup(x => x.LevelFilter).Returns(LevelFlags.All); dataSource.Setup(x => x.Search).Returns(new Mock <ILogFileSearch>().Object); var dataSourceModel = new SingleDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Not a single log entry matches the activated quick filters"); model.NoEntriesSubtext.Should().BeNull(); }
public void TestDataSourceDoesntExist2() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); var emptyReason = new SourceDoesNotExist("E:\\Tailviewer\\somefile.log"); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns(emptyReason); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns((Size?)null); var filteredLogFile = new Mock <ILogSource>(); ILogSourceListener listener = null; filteredLogFile.Setup(x => x.AddListener(It.IsAny <ILogSourceListener>(), It.IsAny <TimeSpan>(), It.IsAny <int>())) .Callback((ILogSourceListener l, TimeSpan t, int i) => listener = l); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Data source does not exist"); model.NoEntriesAction.Should().Be("The data source 'somefile.log' was last seen E:\\Tailviewer"); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.Zero); listener.OnLogFileModified(logFile.Object, LogSourceModification.Appended(0, 0)); model.Update(); model.NoEntriesExplanation.Should().Be("Data source is empty"); model.NoEntriesAction.Should().BeNull(); }
public LogViewerPage(LogViewerViewModel viewModel) { InitializeComponent(); BindingContext = ViewModel = viewModel; viewModel.Navigation = Navigation; }
public MainViewModel() { _settings = new SettingsViewModel(); _logViewer = new LogViewerViewModel(); _board = new BoardViewModel(); _context = new WorkContext(); _views = new ViewsViewModel(); }
private void OpenFile(IDataSourceViewModel dataSource) { if (dataSource != null) { CurrentDataSource = dataSource; CurrentDataSourceLogView = new LogViewerViewModel( dataSource, _actionCenter, _applicationSettings); } else { CurrentDataSource = null; CurrentDataSourceLogView = null; } }
protected override void OnViewModelChanged() { base.OnViewModelChanged(); if (_lastKnownViewModel != null) { _lastKnownViewModel.LogMessage -= OnViewModelLogMessage; _lastKnownViewModel = null; } _lastKnownViewModel = ViewModel as LogViewerViewModel; if (_lastKnownViewModel != null) { _lastKnownViewModel.LogMessage += OnViewModelLogMessage; } }
public void TestDataSourceNoFiles() { var dataSource = new Mock <IFolderDataSource>(); var logFile = new Mock <ILogFile>(); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.UnfilteredFileCount).Returns(0); dataSource.Setup(x => x.FilteredFileCount).Returns(0); dataSource.Setup(x => x.OriginalSources).Returns(new List <IDataSource>()); dataSource.Setup(x => x.FullFileName).Returns(@"F:\logs\today"); var dataSourceModel = new FolderDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("The folder \"today\" does not contain any file"); model.NoEntriesSubtext.Should().Be(@"F:\logs\today"); }
public void TestSearch1() { using ( var dataSource = new SingleDataSource(_logFileFactory, _scheduler, new DataSource(TextLogFileAcceptanceTest.File20Mb) { Id = DataSourceId.CreateNew() })) { var dataSourceModel = new SingleDataSourceViewModel(dataSource, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings, TimeSpan.Zero); dataSourceModel.SearchTerm = "i"; dataSource.FilteredLogFile.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(20)); // We have waited for that filter operation to finish, HOWEVER, did not invoke the dispatcher. // This causes all modifications from that operation to stay in the view-model's queue dataSourceModel.SearchTerm = "in"; dataSourceModel.SearchTerm = "inf"; dataSourceModel.SearchTerm = "info"; // Now we wait for the very last filter operation to complete dataSource.FilteredLogFile.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(20)); // And then dispatch ALL events at ONCE. // We expect the view model to completely ignore the old changes! model.Update(); /*model.LogEntryCount.Should().Be(5); * model.LogEntries.Select(x => x.Message) * .Should().Equal(new[] * { * "2015-10-07 19:50:58,982 [8092, 1] INFO SharpRemote.Hosting.OutOfProcessSiloServer (null) - Silo Server starting, args (1): \"14056\", without custom type resolver" * , * "2015-10-07 19:50:59,081 [8092, 1] INFO SharpRemote.SocketRemotingEndPointServer (null) - EndPoint '<Unnamed>' listening on 0.0.0.0:49152" * , * "2015-10-07 19:50:59,171 [8092, 6] INFO SharpRemote.AbstractIPSocketRemotingEndPoint (null) - <Unnamed>: Connected to 127.0.0.1:10348" * , * "2015-10-07 19:51:42,481 [8092, EndPoint '<Unnamed>' Socket Reading] INFO SharpRemote.AbstractSocketRemotingEndPoint (null) - Disconnecting socket '<Unnamed>' from 127.0.0.1:10348: ReadFailure" * , * "2015-10-07 19:51:42,483 [8092, 6] INFO SharpRemote.Hosting.OutOfProcessSiloServer (null) - Parent process terminated unexpectedly (exit code: -1), shutting down..." * });*/ } }
public void TestChangeLogView2() { var dataSource = new Mock <IDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.Count).Returns(100); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogFile).Returns(logFile.Object); var dataSourceViewModel = new Mock <IDataSourceViewModel>(); dataSourceViewModel.Setup(x => x.DataSource).Returns(dataSource.Object); dataSourceViewModel.Setup(x => x.VisibleLogLine).Returns(new LogLineIndex(42)); var logView = new LogViewerViewModel(dataSourceViewModel.Object, _actionCenter.Object, _settings.Object); _control.LogView = logView; _control.CurrentLogLine.Should().Be(42); _control.PartListView.CurrentLine.Should().Be(42); _control.PartListView.PartTextCanvas.CurrentLine.Should().Be(42); }
public void TestDataSourceEmpty() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.Zero); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Data source is empty"); model.NoEntriesAction.Should().BeNull(); }
protected override void OnViewModelChanged() { base.OnViewModelChanged(); if (_lastKnownViewModel != null) { _lastKnownViewModel.LogMessage -= OnViewModelLogMessage; _lastKnownViewModel.ActiveFilterGroupChanged -= OnViewModelActiveFilterGroupChanged; _lastKnownViewModel = null; } _lastKnownViewModel = ViewModel as LogViewerViewModel; if (_lastKnownViewModel != null) { _lastKnownViewModel.LogMessage += OnViewModelLogMessage; _lastKnownViewModel.ActiveFilterGroupChanged += OnViewModelActiveFilterGroupChanged; } ScrollToEnd(); }
public void TestDataSourceNoMatchingFiles() { var dataSource = new Mock <IFolderDataSource>(); var logFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.UnfilteredFileCount).Returns(1); dataSource.Setup(x => x.FilteredFileCount).Returns(0); dataSource.Setup(x => x.OriginalSources).Returns(new List <IDataSource>()); dataSource.Setup(x => x.FullFileName).Returns(@"C:\logs\yesterday"); dataSource.Setup(x => x.LogFileSearchPattern).Returns("*.foo"); var dataSourceModel = CreateFolderViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("The folder \"yesterday\" does not contain any file matching \"*.foo\""); model.NoEntriesAction.Should().Be(@"C:\logs\yesterday"); }
public void TestDataSourceDoesntExist1() { var dataSource = new Mock <ISingleDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.SourceDoesNotExist); var filteredLogFile = new Mock <ILogFile>(); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogFile).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogFileSearch>().Object); var dataSourceModel = new SingleDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Can't find \"somefile.log\""); model.NoEntriesSubtext.Should().Be("It was last seen at E:\\Tailviewer"); }
public void TestDataSourceEmpty() { var dataSource = new Mock <ISingleDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.None); logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(Size.Zero); var filteredLogFile = new Mock <ILogFile>(); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogFile).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogFileSearch>().Object); var dataSourceModel = new SingleDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("The data source is empty"); model.NoEntriesSubtext.Should().BeNull(); }
public void TestDataSourceCannotBeAccessed1() { var dataSource = new Mock <ISingleDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.SourceCannotBeAccessed); var filteredLogFile = new Mock <ILogFile>(); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogFile).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogFileSearch>().Object); var dataSourceModel = new SingleDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Unable to access \"somefile.log\""); model.NoEntriesSubtext.Should().Be("The file may be opened exclusively by another process or you are not authorized to view it"); }
public void TestDataSourceCannotBeAccessed1() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); var emptyReason = new SourceCannotBeAccessed("E:\\Tailviewer\\somefile.log"); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns(emptyReason); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Data source cannot be opened"); model.NoEntriesAction.Should().Be("The file 'somefile.log' may be opened exclusively by another process or you are not authorized to view it"); }
public void TestDataSourceDoesntExist1() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); var emptyReason = new SourceDoesNotExist("E:\\Tailviewer\\somefile.log"); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns(emptyReason); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FullFileName).Returns(@"E:\Tailviewer\somefile.log"); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Data source does not exist"); model.NoEntriesAction.Should().Be("The data source 'somefile.log' was last seen E:\\Tailviewer"); }
public void TestLevelFilter1([ValueSource(nameof(NotAll))] LevelFlags flags) { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.LogEntryCount)).Returns(1); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.LevelFilter).Returns(flags); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Nothing matches level filter"); model.NoEntriesAction.Should().Be("Try filtering by different levels or display everything regardless of its level again"); }
public void TestLevelFilter1([ValueSource(nameof(NotAll))] LevelFlags flags) { var dataSource = new Mock <ISingleDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.None); logFile.Setup(x => x.Count).Returns(1); logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogFile>(); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogFile).Returns(filteredLogFile.Object); dataSource.Setup(x => x.LevelFilter).Returns(flags); dataSource.Setup(x => x.Search).Returns(new Mock <ILogFileSearch>().Object); var dataSourceModel = new SingleDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Not a single log entry matches the level selection"); model.NoEntriesSubtext.Should().BeNull(); }
public void TestStringFilter() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.LogEntryCount)).Returns(1); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.LogEntryFilter).Returns(new SubstringFilter("s", true)); dataSource.Setup(x => x.LevelFilter).Returns(LevelFlags.All); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Nothing matches quick filter"); model.NoEntriesAction.Should().Be("Try filtering by different terms or disable all quick filters"); }
public void TestTimeFilter() { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.LogEntryCount)).Returns(1); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.LogEntryFilter).Returns(FilterExpression.Parse("today contains $timestamp")); dataSource.Setup(x => x.LevelFilter).Returns(LevelFlags.All); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Nothing matches quick filter"); model.NoEntriesAction.Should().Be("No log entry matches \"today contains $timestamp\".\r\nTry changing your filter(s) or disable them again"); }
/// <summary> /// Initializes a LogViewer window with the given vertices and steps /// </summary> public LogViewer(Vec3[] vertices, StepInfo[] steps, string title = null) { InitializeComponent(); if (title != null) { Title = title; } //Categorizes buttons to enable hiding of groups var toggleBtns = new[] { settingsToggle, cameraToggle, logToggle, colorToggle }; var camBtns = new[] { cameraChange, cameraReset }; var settingBtns = new UIElement[] { faceToggle, vertToggle, meshToggle, wireframeToggle, export, smoothToggle }; var colorBtns = new UIElement[] { faceColor, vertColor, wireColor, cubeColor, colTxtFace, colTxtVert, colTxtWire, colTxtCube }; var logBtns = new UIElement[] { logIncrement, logDecrement, seconds, secText, logRun, logMaxvalue, logCurrent }; //Initializes the ViewModel and sets up Commands var vm = new LogViewerViewModel(Viewer, seconds, vertices, steps, toggleBtns, camBtns, settingBtns, colorBtns, logBtns); vm.CameraControl = new RelayCommand(o => vm.ChangeCameraSetting()); vm.CameraResetControl = new RelayCommand(o => vm.ResetCamera()); vm.WireframeControl = new RelayCommand(o => vm.ToggleWireframe()); vm.IncrementControl = new RelayCommand(o => vm.IncrementStep()); vm.DecrementControl = new RelayCommand(o => vm.DecrementStep()); vm.FacesControl = new RelayCommand(o => vm.ToggleFaces()); vm.FullMeshControl = new RelayCommand(o => vm.ToggleFullMesh()); vm.VertControl = new RelayCommand(o => vm.ToggleVertices()); vm.ExportControl = new RelayCommand(o => vm.Export()); vm.AutoRunControl = new RelayCommand(o => vm.AutoRun()); vm.SmoothControl = new RelayCommand(o => vm.ToggleSmooth()); DataContext = vm; }
public void TestChangeLogView1() { // TODO: This test requires that the template be fully loaded (or the control changed to a user control) var oldLog = new Mock <IDataSourceViewModel>(); var oldDataSource = new Mock <IDataSource>(); var oldLogFile = new Mock <ILogFile>(); oldLogFile.Setup(x => x.Count).Returns(10000); oldDataSource.Setup(x => x.FilteredLogFile).Returns(oldLogFile.Object); oldDataSource.Setup(x => x.UnfilteredLogFile).Returns(new Mock <ILogFile>().Object); oldLog.Setup(x => x.DataSource).Returns(oldDataSource.Object); oldLog.SetupProperty(x => x.VisibleLogLine); oldLog.Object.VisibleLogLine = 42; var oldLogView = new LogViewerViewModel(oldLog.Object, _actionCenter.Object, _settings.Object); _control.LogView = oldLogView; var newLog = new Mock <IDataSourceViewModel>(); var newDataSource = new Mock <IDataSource>(); newDataSource.Setup(x => x.FilteredLogFile).Returns(new Mock <ILogFile>().Object); newDataSource.Setup(x => x.UnfilteredLogFile).Returns(new Mock <ILogFile>().Object); newLog.Setup(x => x.DataSource).Returns(newDataSource.Object); newLog.SetupProperty(x => x.VisibleLogLine); newLog.Object.VisibleLogLine = 1; var newLogView = new LogViewerViewModel(newLog.Object, _actionCenter.Object, _settings.Object); _control.LogView = newLogView; oldLog.Object.VisibleLogLine.Should() .Be(42, "Because the control shouldn't have changed the VisibleLogLine of the old logview"); newLog.Object.VisibleLogLine.Should() .Be(1, "Because the control shouldn't have changed the VisibleLogLine of the old logview"); }