-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Outlines now also work for multi data sources #207
- Loading branch information
1 parent
eafa137
commit 9f3f763
Showing
4 changed files
with
101 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/Tailviewer.Test/Ui/Controls/SidePanel/Outline/OutlineViewModelTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
using System.Threading; | ||
using System.Windows; | ||
using FluentAssertions; | ||
using Moq; | ||
using NUnit.Framework; | ||
using Tailviewer.Archiver.Plugins; | ||
using Tailviewer.BusinessLogic.DataSources; | ||
using Tailviewer.BusinessLogic.LogFiles; | ||
using Tailviewer.Core; | ||
using Tailviewer.Ui.Controls.SidePanel.Outline; | ||
using Tailviewer.Ui.Outline; | ||
|
||
namespace Tailviewer.Test.Ui.Controls.SidePanel.Outline | ||
{ | ||
[TestFixture] | ||
[Apartment(ApartmentState.STA)] | ||
public sealed class OutlineViewModelTest | ||
{ | ||
private ServiceContainer _services; | ||
private PluginRegistry _pluginLoader; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_services = new ServiceContainer(); | ||
_pluginLoader = new PluginRegistry(); | ||
_services.RegisterInstance<IPluginLoader>(_pluginLoader); | ||
} | ||
|
||
[Test] | ||
public void TestMultiSource() | ||
{ | ||
var plugin = new Mock<ILogFileOutlinePlugin>(); | ||
plugin.Setup(x => x.SupportedFileNames).Returns(new[] {new Regex(@"Apache\.log"),}); | ||
plugin.Setup(x => x.CreateViewModel(It.IsAny<IServiceContainer>(), It.IsAny<ILogFile>())) | ||
.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 OutlineViewModel(_services); | ||
|
||
var dataSource = new Mock<IMultiDataSource>(); | ||
var logFile = new Mock<ILogFile>(); | ||
dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); | ||
dataSource.Setup(x => x.OriginalSources).Returns(new[]{CreateDataSource(fileName: "Foo"), CreateDataSource(fileName: "Apache.log")}); | ||
|
||
viewModel.CurrentContent.Should().BeNull(); | ||
viewModel.CurrentDataSource.Should().BeNull(); | ||
|
||
viewModel.CurrentDataSource = dataSource.Object; | ||
plugin.Verify(x => x.CreateViewModel(_services, logFile.Object), Times.Once); | ||
viewModel.CurrentContent.Should().BeSameAs(pluginContent); | ||
} | ||
|
||
private IDataSource CreateDataSource(string fileName) | ||
{ | ||
var dataSource = new Mock<IDataSource>(); | ||
dataSource.Setup(x => x.FullFileName).Returns(fileName); | ||
return dataSource.Object; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters