Add test for directory search query string and method

This commit is contained in:
Jeremy Wu 2020-05-12 06:50:17 +10:00
parent 26f0ce2778
commit f4ae5badf5
3 changed files with 29 additions and 1 deletions

View file

@ -24,6 +24,21 @@ namespace Flow.Launcher.Test.Plugins
$"Actual: {result}{Environment.NewLine}");
}
[TestCase("C:\\Dropbox", "SELECT TOP 100 System.FileName, System.ItemPathDisplay FROM SystemIndex WHERE directory='file:C:\\Dropbox'")]
public void GivenWindowsIndexSearch_WhenSearchTypeIsSearchTopFolderLevel_ThenQueryShouldUseExpectedString(string folderPath, string expectedString)
{
// Given
var queryConstructor = new QueryConstructor(new Settings());
//When
var queryString = queryConstructor.QueryForTopLevelDirectorySearch(folderPath);
Assert.IsTrue(queryString == expectedString,
$"Expected QueryWhereRestrictions string: {expectedString}{Environment.NewLine} " +
$"Actual string was: {queryString}{Environment.NewLine}");
}
public void GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryWhereRestrictionsShouldUseScopeString() { }
public void GivenWindowsIndexSearch_WhenReturnedNilAndIsNotIndexed_ThenSearchMethodShouldContinueDirectoryInfoClassSearch() { }

View file

@ -16,6 +16,10 @@
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Explorer</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="tlbimp-Microsoft.Search.Interop" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />

View file

@ -1,4 +1,4 @@
using Microsoft.Search.Interop;
using Microsoft.Search.Interop;
using System;
using System.Collections.Generic;
using System.Text;
@ -51,5 +51,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
return $"directory='file:{path}'";
}
public string QueryForTopLevelDirectorySearch(string folderPath)
{
string query = "SELECT TOP " + _settings.MaxResult + $" {CreateBaseQuery().QuerySelectColumns} FROM {SystemIndex} WHERE ";
query += QueryWhereRestrictionsForTopLevelDirectorySearch(folderPath);
return query;
}
}
}