Add Windows Index directory search query test

This commit is contained in:
Jeremy Wu 2020-05-11 23:19:41 +10:00
parent 8848ed1a00
commit 6d7aa46747
4 changed files with 46 additions and 1 deletions

View file

@ -39,6 +39,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Explorer\Flow.Launcher.Plugin.Explorer.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Program\Flow.Launcher.Plugin.Program.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Url\Flow.Launcher.Plugin.Url.csproj" />
<ProjectReference Include="..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />

View file

@ -1,11 +1,28 @@
using Flow.Launcher.Plugin.Explorer;
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
using NUnit.Framework;
using System;
namespace Flow.Launcher.Test.Plugins
{
[TestFixture]
public class ExplorerTest
{
public void GivenWindowsIndexSearch_WhenProvidedFolderPath_ThenQueryWhereRestrictionsShouldUseDirectoryString(string expectedString){}
[TestCase("directory='file:{path}'")]
public void GivenWindowsIndexSearch_WhenProvidedFolderPath_ThenQueryWhereRestrictionsShouldUseDirectoryString(string expectedString)
{
// Given
var queryConstructor = new QueryConstructor(new Settings());
// When
var path = @"C:\Dropbox";
var result = queryConstructor.QueryWhereRestrictionsForTopLevelDirectorySearch(path);
// Then
Assert.IsTrue(result == expectedString,
$"Expected QueryWhereRestrictions string: {expectedString}{Environment.NewLine} " +
$"Actual: {result}{Environment.NewLine}");
}
public void GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryWhereRestrictionsShouldUseScopeString() { }

View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
{
public class QueryConstructor
{
private Settings _settings;
public QueryConstructor(Settings settings)
{
_settings = settings;
}
///<summary>
/// Search will be performed on all folders and files on the first level of a specified directory.
///</summary>
public string QueryWhereRestrictionsForTopLevelDirectorySearch(string path)
{
// Set query restriction for top level directory search
return $"directory='file:{path}'";
}
}
}

View file

@ -6,5 +6,6 @@ namespace Flow.Launcher.Plugin.Explorer
{
public class Settings
{
public int MaxResult { get; set; } = 100;
}
}