public void TestMultiSource() { var plugin = new Mock <ILogFileOutlinePlugin>(); plugin.Setup(x => x.SupportedFormats).Returns(new[] { LogFileFormats.ExtendedLogFormat }); plugin.Setup(x => x.CreateViewModel(It.IsAny <IServiceContainer>(), It.IsAny <ILogSource>())) .Returns(new Mock <ILogFileOutlineViewModel>().Object); var pluginContent = new FrameworkElement(); plugin.Setup(x => x.CreateContentPresenterFor(It.IsAny <IServiceContainer>(), It.IsAny <ILogFileOutlineViewModel>())) .Returns(pluginContent); _pluginLoader.Register(plugin.Object); var viewModel = new OutlineSidePanelViewModel(_services); var dataSource = new Mock <IMultiDataSource>(); var logFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.OriginalSources).Returns(new[] { CreateDataSource(LogFileFormats.CommonLogFormat), CreateDataSource(LogFileFormats.ExtendedLogFormat) }); viewModel.CurrentContent.Should().BeNull(); viewModel.CurrentDataSource.Should().BeNull(); viewModel.EmptyStatement.Should().NotBeNull(); viewModel.EmptyExplanation.Should().NotBeNull(); viewModel.CurrentDataSource = dataSource.Object; plugin.Verify(x => x.CreateViewModel(_services, logFile.Object), Times.Once); viewModel.CurrentContent.Should().BeSameAs(pluginContent); viewModel.EmptyStatement.Should().BeNull(); viewModel.EmptyExplanation.Should().BeNull(); }
public void TestConstruction() { var viewModel = new OutlineSidePanelViewModel(_services); viewModel.CurrentDataSource.Should().BeNull(); viewModel.CurrentContent.Should().BeNull(); }
public void TestConstruction() { var viewModel = new OutlineSidePanelViewModel(_services); viewModel.CurrentDataSource.Should().BeNull(); viewModel.CurrentContent.Should().BeNull(); viewModel.EmptyStatement.Should().Be("No outline plugin installed"); viewModel.EmptyExplanation.Should().Be("There is no plugin installed which is able to present an outline for the current data source's log format."); }
public void TestUnsetCurrentDataSource() { var viewModel = new OutlineSidePanelViewModel(_services); var dataSource = new Mock <IDataSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(new InMemoryLogSource()); viewModel.CurrentDataSource = dataSource.Object; viewModel.CurrentDataSource.Should().Be(dataSource.Object); viewModel.CurrentDataSource = null; viewModel.CurrentDataSource.Should().BeNull(); }
public LogViewMainPanelViewModel(IServiceContainer services, IActionCenter actionCenter, IDataSources dataSources, IQuickFilters quickFilters, IHighlighters highlighters, IApplicationSettings applicationSettings) : base(applicationSettings) { if (actionCenter == null) { throw new ArgumentNullException(nameof(actionCenter)); } _applicationSettings = applicationSettings; _actionCenter = actionCenter; _dataSources = new DataSourcesViewModel(applicationSettings, dataSources, _actionCenter); _dataSources.PropertyChanged += DataSourcesOnPropertyChanged; _quickFilters = new QuickFiltersSidePanelViewModel(applicationSettings, quickFilters); _quickFilters.OnFiltersChanged += OnFiltersChanged; _highlighters = new HighlightersSidePanelViewModel(highlighters); _goToLine = new GoToLineViewModel(); _goToLine.LineNumberChosen += GoToLineOnLineNumberChosen; _quickNavigation = new QuickNavigationViewModel(dataSources); _quickNavigation.DataSourceChosen += QuickNavigationOnDataSourceChosen; _bookmarks = new BookmarksViewModel(dataSources, OnNavigateToBookmark); _outline = new OutlineSidePanelViewModel(services); _issues = new IssuesSidePanelViewModel(services); _sidePanels = new ISidePanelViewModel[] { _dataSources, _quickFilters, //_highlighters, _bookmarks, _outline, _issues }; SelectedSidePanel = _sidePanels.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow?.SelectedSidePanel); PropertyChanged += OnPropertyChanged; ChangeDataSource(CurrentDataSource); }