Matching ExactName for known Win32 Programs (#6924)

* Matching explorer.exe also for explorer
Added unit test
Optimized multiple iterations for IProgram

* Fixed linter

Co-authored-by: p-storm <paul.de.man@gmail.com>
This commit is contained in:
P-Storm
2020-10-07 18:23:47 +02:00
committed by GitHub
parent a2fce22973
commit 8b66932036
4 changed files with 52 additions and 27 deletions

View File

@@ -63,7 +63,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
AppType = Win32Program.ApplicationType.Win32Application,
};
private static readonly Win32Program _fileExplorer = new Win32Program
private static readonly Win32Program _fileExplorerLink = new Win32Program
{
Name = "File Explorer",
ExecutableName = "File Explorer.lnk",
@@ -72,6 +72,15 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
AppType = Win32Program.ApplicationType.Win32Application,
};
private static readonly Win32Program _fileExplorer = new Win32Program
{
Name = "File Explorer",
ExecutableName = "explorer.exe",
FullPath = "c:\\windows\\explorer.exe",
LnkResolvedPath = null,
AppType = Win32Program.ApplicationType.Win32Application,
};
private static readonly Win32Program _wordpad = new Win32Program
{
Name = "Wordpad",
@@ -273,7 +282,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
// Arrange
List<Win32Program> prgms = new List<Win32Program>
{
_fileExplorer,
_fileExplorerLink,
};
// Act
@@ -403,6 +412,14 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsTrue(_commandPrompt.QueryEqualsNameForRunCommands(query));
}
[TestCase("explorer")]
[TestCase("explorer.exe")]
public void Win32ApplicationsShouldNotFilterWhenExecutingNameOrNameIsUsed(string query)
{
// Even if there is an exact match in the name or exe name, win32 applications should never be filtered
Assert.IsTrue(_fileExplorer.QueryEqualsNameForRunCommands(query));
}
[TestCase("cmd")]
[TestCase("Cmd")]
[TestCase("CMD")]