diff --git a/Flow.Launcher.Test/Flow.Launcher.Test.csproj b/Flow.Launcher.Test/Flow.Launcher.Test.csproj index 2dbf1a9d3..e5ca36289 100644 --- a/Flow.Launcher.Test/Flow.Launcher.Test.csproj +++ b/Flow.Launcher.Test/Flow.Launcher.Test.csproj @@ -39,6 +39,7 @@ + diff --git a/Flow.Launcher.Test/Plugins/ExplorerTest.cs b/Flow.Launcher.Test/Plugins/ExplorerTest.cs index 2bc95d086..c0fa32f5b 100644 --- a/Flow.Launcher.Test/Plugins/ExplorerTest.cs +++ b/Flow.Launcher.Test/Plugins/ExplorerTest.cs @@ -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() { } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs new file mode 100644 index 000000000..9d5ffdb30 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs @@ -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; + } + + /// + /// Search will be performed on all folders and files on the first level of a specified directory. + /// + public string QueryWhereRestrictionsForTopLevelDirectorySearch(string path) + { + // Set query restriction for top level directory search + return $"directory='file:{path}'"; + } + + } +} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index dcdb8f06e..2d664c3db 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -6,5 +6,6 @@ namespace Flow.Launcher.Plugin.Explorer { public class Settings { + public int MaxResult { get; set; } = 100; } }