mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
remove the indexer plugin from constant search plugins (#8367)
This commit is contained in:
@@ -368,90 +368,5 @@ namespace Wox.Test.Plugins
|
||||
// Act & Assert
|
||||
return driveDetection.DisplayWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimplifyQueryShouldRemoveLikeQueryWhenSQLQueryUsesLIKESyntax()
|
||||
{
|
||||
// Arrange
|
||||
string sqlQuery = "SELECT TOP 30 \"System.ItemUrl\", \"System.FileName\", \"System.FileAttributes\" FROM \"SystemIndex\" WHERE (System.FileName LIKE 'abcd.%' OR CONTAINS(System.FileName,'\"abcd.*\"',1033)) AND scope='file:' ORDER BY System.DateModified DESC";
|
||||
|
||||
// Act
|
||||
var simplifiedSqlQuery = WindowsSearchAPI.SimplifyQuery(sqlQuery);
|
||||
|
||||
// Assert
|
||||
string expectedSqlQuery = "SELECT TOP 30 \"System.ItemUrl\", \"System.FileName\", \"System.FileAttributes\" FROM \"SystemIndex\" WHERE (CONTAINS(System.FileName,'\"abcd.*\"',1033)) AND scope='file:' ORDER BY System.DateModified DESC";
|
||||
|
||||
// Using InvariantCultureIgnoreCase since this relates to sql code in string form
|
||||
Assert.IsFalse(simplifiedSqlQuery.Equals(sqlQuery, StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(simplifiedSqlQuery.Equals(expectedSqlQuery, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimplifyQueryShouldReturnArgumentWhenSQLQueryDoesNotUseLIKESyntax()
|
||||
{
|
||||
// Arrange
|
||||
string sqlQuery = "SELECT TOP 30 \"System.ItemUrl\", \"System.FileName\", \"System.FileAttributes\" FROM \"SystemIndex\" WHERE CONTAINS(System.FileName,'\"abcd*\"',1033) AND scope='file:' ORDER BY System.DateModified DESC";
|
||||
|
||||
// Act
|
||||
var simplifiedSqlQuery = WindowsSearchAPI.SimplifyQuery(sqlQuery);
|
||||
|
||||
// Assert
|
||||
// Using InvariantCultureIgnoreCase since this relates to sql code in string form
|
||||
Assert.IsTrue(simplifiedSqlQuery.Equals(sqlQuery, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimplifyQueryShouldRemoveAllOccurrencesOfLikeQueryWhenSQLQueryUsesLIKESyntaxMultipleTimes()
|
||||
{
|
||||
// Arrange
|
||||
string sqlQuery = "SELECT TOP 30 \"System.ItemUrl\", \"System.FileName\", \"System.FileAttributes\", \"System.FileExtension\" FROM \"SystemIndex\" WHERE (System.FileName LIKE 'ab.%' OR CONTAINS(System.FileName,'\"ab.*\"',1033)) AND (System.FileExtension LIKE '.cd%' OR CONTAINS(System.FileName,'\".cd*\"',1033)) AND scope='file:' ORDER BY System.DateModified DESC";
|
||||
|
||||
// Act
|
||||
var simplifiedSqlQuery = WindowsSearchAPI.SimplifyQuery(sqlQuery);
|
||||
|
||||
// Assert
|
||||
string expectedSqlQuery = "SELECT TOP 30 \"System.ItemUrl\", \"System.FileName\", \"System.FileAttributes\", \"System.FileExtension\" FROM \"SystemIndex\" WHERE (CONTAINS(System.FileName,'\"ab.*\"',1033)) AND (CONTAINS(System.FileName,'\".cd*\"',1033)) AND scope='file:' ORDER BY System.DateModified DESC";
|
||||
|
||||
// Using InvariantCultureIgnoreCase since this relates to sql code in string form
|
||||
Assert.IsFalse(simplifiedSqlQuery.Equals(sqlQuery, StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(simplifiedSqlQuery.Equals(expectedSqlQuery, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimplifyQueryShouldRemoveLikeQueryWhenSQLQueryUsesLIKESyntaxAndContainsEscapedSingleQuotationMarks()
|
||||
{
|
||||
// Arrange
|
||||
string sqlQuery = "SELECT TOP 30 \"System.ItemUrl\", \"System.FileName\", \"System.FileAttributes\" FROM \"SystemIndex\" WHERE (System.FileName LIKE '''ab.cd''%' OR CONTAINS(System.FileName,'\"'ab.cd'*\"',1033)) AND scope='file:' ORDER BY System.DateModified DESC";
|
||||
|
||||
// Act
|
||||
var simplifiedSqlQuery = WindowsSearchAPI.SimplifyQuery(sqlQuery);
|
||||
|
||||
// Assert
|
||||
string expectedSqlQuery = "SELECT TOP 30 \"System.ItemUrl\", \"System.FileName\", \"System.FileAttributes\" FROM \"SystemIndex\" WHERE (CONTAINS(System.FileName,'\"'ab.cd'*\"',1033)) AND scope='file:' ORDER BY System.DateModified DESC";
|
||||
|
||||
// Using InvariantCultureIgnoreCase since this relates to sql code in string form
|
||||
Assert.IsFalse(simplifiedSqlQuery.Equals(sqlQuery, StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(simplifiedSqlQuery.Equals(expectedSqlQuery, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WindowsSearchAPIShouldReturnEmptyResultsWhenIsFullQueryIsTrueAndTheQueryDoesNotRequireLIKESyntax()
|
||||
{
|
||||
// Arrange
|
||||
OleDBResult file1 = new OleDBResult(new List<object>() { "C:/test/path/file1.txt", DBNull.Value });
|
||||
OleDBResult file2 = new OleDBResult(new List<object>() { "C:/test/path/file2.txt", "file2.txt" });
|
||||
|
||||
List<OleDBResult> results = new List<OleDBResult>() { file1, file2 };
|
||||
var mock = new Mock<ISearch>();
|
||||
mock.Setup(x => x.Query(It.IsAny<string>(), It.IsAny<string>())).Returns(results);
|
||||
WindowsSearchAPI api = new WindowsSearchAPI(mock.Object, false);
|
||||
var searchManager = GetMockSearchManager();
|
||||
|
||||
// Act
|
||||
var windowsSearchAPIResults = api.Search("file", searchManager, true);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(!windowsSearchAPIResults.Any());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user