mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Fix all file naming tweaks (#5945)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!--<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||||
<Link>GlobalSuppressions.cs</Link>
|
<Link>GlobalSuppressions.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -60,5 +60,5 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>-->
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class Win32Tests
|
public class Win32Tests
|
||||||
{
|
{
|
||||||
private static Win32Program notepad_appdata = new Win32Program
|
private static readonly Win32Program _notepadAppdata = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Notepad",
|
Name = "Notepad",
|
||||||
ExecutableName = "notepad.exe",
|
ExecutableName = "notepad.exe",
|
||||||
@@ -26,7 +26,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program notepad_users = new Win32Program
|
private static readonly Win32Program _notepadUsers = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Notepad",
|
Name = "Notepad",
|
||||||
ExecutableName = "notepad.exe",
|
ExecutableName = "notepad.exe",
|
||||||
@@ -35,7 +35,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program azure_command_prompt = new Win32Program
|
private static readonly Win32Program _azureCommandPrompt = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Microsoft Azure Command Prompt - v2.9",
|
Name = "Microsoft Azure Command Prompt - v2.9",
|
||||||
ExecutableName = "cmd.exe",
|
ExecutableName = "cmd.exe",
|
||||||
@@ -44,7 +44,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program visual_studio_command_prompt = new Win32Program
|
private static readonly Win32Program _visualStudioCommandPrompt = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "x64 Native Tools Command Prompt for VS 2019",
|
Name = "x64 Native Tools Command Prompt for VS 2019",
|
||||||
ExecutableName = "cmd.exe",
|
ExecutableName = "cmd.exe",
|
||||||
@@ -53,7 +53,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program command_prompt = new Win32Program
|
private static readonly Win32Program _commandPrompt = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Command Prompt",
|
Name = "Command Prompt",
|
||||||
ExecutableName = "cmd.exe",
|
ExecutableName = "cmd.exe",
|
||||||
@@ -62,7 +62,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program file_explorer = new Win32Program
|
private static readonly Win32Program _fileExplorer = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "File Explorer",
|
Name = "File Explorer",
|
||||||
ExecutableName = "File Explorer.lnk",
|
ExecutableName = "File Explorer.lnk",
|
||||||
@@ -71,7 +71,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program wordpad = new Win32Program
|
private static readonly Win32Program _wordpad = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Wordpad",
|
Name = "Wordpad",
|
||||||
ExecutableName = "wordpad.exe",
|
ExecutableName = "wordpad.exe",
|
||||||
@@ -80,7 +80,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program wordpad_duplicate = new Win32Program
|
private static readonly Win32Program _wordpadDuplicate = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "WORDPAD",
|
Name = "WORDPAD",
|
||||||
ExecutableName = "WORDPAD.EXE",
|
ExecutableName = "WORDPAD.EXE",
|
||||||
@@ -89,7 +89,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program twitter_pwa = new Win32Program
|
private static readonly Win32Program _twitterChromePwa = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Twitter",
|
Name = "Twitter",
|
||||||
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome_proxy.exe",
|
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome_proxy.exe",
|
||||||
@@ -98,7 +98,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 0,
|
AppType = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program pinned_webpage = new Win32Program
|
private static readonly Win32Program _pinnedWebpage = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Web page",
|
Name = "Web page",
|
||||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
||||||
@@ -107,7 +107,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 0,
|
AppType = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program edge_named_pinned_webpage = new Win32Program
|
private static readonly Win32Program _edgeNamedPinnedWebpage = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "edge - Bing",
|
Name = "edge - Bing",
|
||||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
||||||
@@ -116,7 +116,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 0,
|
AppType = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program msedge = new Win32Program
|
private static readonly Win32Program _msedge = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Microsoft Edge",
|
Name = "Microsoft Edge",
|
||||||
ExecutableName = "msedge.exe",
|
ExecutableName = "msedge.exe",
|
||||||
@@ -125,7 +125,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program chrome = new Win32Program
|
private static readonly Win32Program _chrome = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Google Chrome",
|
Name = "Google Chrome",
|
||||||
ExecutableName = "chrome.exe",
|
ExecutableName = "chrome.exe",
|
||||||
@@ -134,7 +134,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program dummy_proxy_app = new Win32Program
|
private static readonly Win32Program _dummyProxyApp = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Proxy App",
|
Name = "Proxy App",
|
||||||
ExecutableName = "test_proxy.exe",
|
ExecutableName = "test_proxy.exe",
|
||||||
@@ -143,7 +143,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 2,
|
AppType = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program cmd_run_command = new Win32Program
|
private static readonly Win32Program _cmdRunCommand = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "cmd",
|
Name = "cmd",
|
||||||
ExecutableName = "cmd.exe",
|
ExecutableName = "cmd.exe",
|
||||||
@@ -152,7 +152,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 3, // Run command
|
AppType = 3, // Run command
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program cmder_run_command = new Win32Program
|
private static readonly Win32Program _cmderRunCommand = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Cmder",
|
Name = "Cmder",
|
||||||
Description = "Cmder: Lovely Console Emulator",
|
Description = "Cmder: Lovely Console Emulator",
|
||||||
@@ -162,7 +162,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 3, // Run command
|
AppType = 3, // Run command
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program dummy_internetShortcut_app = new Win32Program
|
private static readonly Win32Program _dummyInternetShortcutApp = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Shop Titans",
|
Name = "Shop Titans",
|
||||||
ExecutableName = "Shop Titans.url",
|
ExecutableName = "Shop Titans.url",
|
||||||
@@ -172,7 +172,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
AppType = 1,
|
AppType = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Win32Program dummy_internetShortcut_app_duplicate = new Win32Program
|
private static readonly Win32Program _dummyInternetShortcutAppDuplicate = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "Shop Titans",
|
Name = "Shop Titans",
|
||||||
ExecutableName = "Shop Titans.url",
|
ExecutableName = "Shop Titans.url",
|
||||||
@@ -188,8 +188,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
// Arrange
|
// Arrange
|
||||||
List<Win32Program> prgms = new List<Win32Program>
|
List<Win32Program> prgms = new List<Win32Program>
|
||||||
{
|
{
|
||||||
notepad_appdata,
|
_notepadAppdata,
|
||||||
notepad_users
|
_notepadUsers,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -205,8 +205,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
// Arrange
|
// Arrange
|
||||||
List<Win32Program> prgms = new List<Win32Program>
|
List<Win32Program> prgms = new List<Win32Program>
|
||||||
{
|
{
|
||||||
dummy_internetShortcut_app,
|
_dummyInternetShortcutApp,
|
||||||
dummy_internetShortcut_app_duplicate
|
_dummyInternetShortcutAppDuplicate,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -222,7 +222,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
// Arrange
|
// Arrange
|
||||||
List<Win32Program> prgms = new List<Win32Program>
|
List<Win32Program> prgms = new List<Win32Program>
|
||||||
{
|
{
|
||||||
file_explorer
|
_fileExplorer,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -238,8 +238,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
// Arrange
|
// Arrange
|
||||||
List<Win32Program> prgms = new List<Win32Program>
|
List<Win32Program> prgms = new List<Win32Program>
|
||||||
{
|
{
|
||||||
wordpad,
|
_wordpad,
|
||||||
wordpad_duplicate
|
_wordpadDuplicate,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -256,9 +256,9 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
// Arrange
|
// Arrange
|
||||||
List<Win32Program> prgms = new List<Win32Program>
|
List<Win32Program> prgms = new List<Win32Program>
|
||||||
{
|
{
|
||||||
azure_command_prompt,
|
_azureCommandPrompt,
|
||||||
visual_studio_command_prompt,
|
_visualStudioCommandPrompt,
|
||||||
command_prompt
|
_commandPrompt,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -272,20 +272,20 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
public void FunctionIsWebApplicationShouldReturnTrueForWebApplications()
|
public void FunctionIsWebApplicationShouldReturnTrueForWebApplications()
|
||||||
{
|
{
|
||||||
// The IsWebApplication(() function must return true for all PWAs and pinned web pages
|
// The IsWebApplication(() function must return true for all PWAs and pinned web pages
|
||||||
Assert.IsTrue(twitter_pwa.IsWebApplication());
|
Assert.IsTrue(_twitterChromePwa.IsWebApplication());
|
||||||
Assert.IsTrue(pinned_webpage.IsWebApplication());
|
Assert.IsTrue(_pinnedWebpage.IsWebApplication());
|
||||||
Assert.IsTrue(edge_named_pinned_webpage.IsWebApplication());
|
Assert.IsTrue(_edgeNamedPinnedWebpage.IsWebApplication());
|
||||||
|
|
||||||
// Should not filter apps whose executable name ends with proxy.exe
|
// Should not filter apps whose executable name ends with proxy.exe
|
||||||
Assert.IsFalse(dummy_proxy_app.IsWebApplication());
|
Assert.IsFalse(_dummyProxyApp.IsWebApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("ignore")]
|
[TestCase("ignore")]
|
||||||
public void FunctionFilterWebApplicationShouldReturnFalseWhenSearchingForTheMainApp(string query)
|
public void FunctionFilterWebApplicationShouldReturnFalseWhenSearchingForTheMainApp(string query)
|
||||||
{
|
{
|
||||||
// Irrespective of the query, the FilterWebApplication() Function must not filter main apps such as edge and chrome
|
// Irrespective of the query, the FilterWebApplication() Function must not filter main apps such as edge and chrome
|
||||||
Assert.IsFalse(msedge.FilterWebApplication(query));
|
Assert.IsFalse(_msedge.FilterWebApplication(query));
|
||||||
Assert.IsFalse(chrome.FilterWebApplication(query));
|
Assert.IsFalse(_chrome.FilterWebApplication(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("edge", ExpectedResult = true)]
|
[TestCase("edge", ExpectedResult = true)]
|
||||||
@@ -297,7 +297,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
[TestCase("Edge Web page", ExpectedResult = false)]
|
[TestCase("Edge Web page", ExpectedResult = false)]
|
||||||
public bool EdgeWebSitesShouldBeFilteredWhenSearchingForEdge(string query)
|
public bool EdgeWebSitesShouldBeFilteredWhenSearchingForEdge(string query)
|
||||||
{
|
{
|
||||||
return pinned_webpage.FilterWebApplication(query);
|
return _pinnedWebpage.FilterWebApplication(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("chrome", ExpectedResult = true)]
|
[TestCase("chrome", ExpectedResult = true)]
|
||||||
@@ -307,7 +307,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
[TestCase("Google Chrome twitter", ExpectedResult = false)]
|
[TestCase("Google Chrome twitter", ExpectedResult = false)]
|
||||||
public bool ChromeWebSitesShouldBeFilteredWhenSearchingForChrome(string query)
|
public bool ChromeWebSitesShouldBeFilteredWhenSearchingForChrome(string query)
|
||||||
{
|
{
|
||||||
return twitter_pwa.FilterWebApplication(query);
|
return _twitterChromePwa.FilterWebApplication(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("twitter", 0, ExpectedResult = false)]
|
[TestCase("twitter", 0, ExpectedResult = false)]
|
||||||
@@ -318,25 +318,24 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
[TestCase("WEB PAGE", 1, ExpectedResult = false)]
|
[TestCase("WEB PAGE", 1, ExpectedResult = false)]
|
||||||
[TestCase("edge", 2, ExpectedResult = false)]
|
[TestCase("edge", 2, ExpectedResult = false)]
|
||||||
[TestCase("EDGE", 2, ExpectedResult = false)]
|
[TestCase("EDGE", 2, ExpectedResult = false)]
|
||||||
public bool PinnedWebPagesShouldNotBeFilteredWhenSearchingForThem(string query, int Case)
|
public bool PinnedWebPagesShouldNotBeFilteredWhenSearchingForThem(string query, int scenario)
|
||||||
{
|
{
|
||||||
const uint CASE_TWITTER = 0;
|
const int CASE_TWITTER = 0;
|
||||||
const uint CASE_WEB_PAGE = 1;
|
const int CASE_WEB_PAGE = 1;
|
||||||
const uint CASE_EDGE_NAMED_WEBPAGE = 2;
|
const int CASE_EDGE_NAMED_WEBPAGE = 2;
|
||||||
|
|
||||||
// If the query is a part of the name of the web application, it should not be filtered,
|
// If the query is a part of the name of the web application, it should not be filtered,
|
||||||
// even if the name is the same as that of the main application, eg: case 2 - edge
|
// even if the name is the same as that of the main application, eg: case 2 - edge
|
||||||
if (Case == CASE_TWITTER)
|
switch (scenario)
|
||||||
{
|
{
|
||||||
return twitter_pwa.FilterWebApplication(query);
|
case CASE_TWITTER:
|
||||||
}
|
return _twitterChromePwa.FilterWebApplication(query);
|
||||||
else if (Case == CASE_WEB_PAGE)
|
case CASE_WEB_PAGE:
|
||||||
{
|
return _pinnedWebpage.FilterWebApplication(query);
|
||||||
return pinned_webpage.FilterWebApplication(query);
|
case CASE_EDGE_NAMED_WEBPAGE:
|
||||||
}
|
return _edgeNamedPinnedWebpage.FilterWebApplication(query);
|
||||||
else if (Case == CASE_EDGE_NAMED_WEBPAGE)
|
default:
|
||||||
{
|
break;
|
||||||
return edge_named_pinned_webpage.FilterWebApplication(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// unreachable code
|
// unreachable code
|
||||||
@@ -350,7 +349,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
public void Win32ApplicationsShouldNotBeFilteredWhenFilteringRunCommands(string query)
|
public void Win32ApplicationsShouldNotBeFilteredWhenFilteringRunCommands(string query)
|
||||||
{
|
{
|
||||||
// Even if there is an exact match in the name or exe name, win32 applications should never be filtered
|
// Even if there is an exact match in the name or exe name, win32 applications should never be filtered
|
||||||
Assert.IsTrue(command_prompt.QueryEqualsNameForRunCommands(query));
|
Assert.IsTrue(_commandPrompt.QueryEqualsNameForRunCommands(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("cmd")]
|
[TestCase("cmd")]
|
||||||
@@ -359,10 +358,10 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
public void RunCommandsShouldNotBeFilteredOnExactMatch(string query)
|
public void RunCommandsShouldNotBeFilteredOnExactMatch(string query)
|
||||||
{
|
{
|
||||||
// Partial matches should be filtered as cmd is not equal to cmder
|
// Partial matches should be filtered as cmd is not equal to cmder
|
||||||
Assert.IsFalse(cmder_run_command.QueryEqualsNameForRunCommands(query));
|
Assert.IsFalse(_cmderRunCommand.QueryEqualsNameForRunCommands(query));
|
||||||
|
|
||||||
// the query matches the name (cmd) and is therefore not filtered (case-insensitive)
|
// the query matches the name (cmd) and is therefore not filtered (case-insensitive)
|
||||||
Assert.IsTrue(cmd_run_command.QueryEqualsNameForRunCommands(query));
|
Assert.IsTrue(_cmdRunCommand.QueryEqualsNameForRunCommands(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -373,7 +372,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
List<ContextMenuResult> contextMenuResults = pinned_webpage.ContextMenus(mock.Object);
|
List<ContextMenuResult> contextMenuResults = _pinnedWebpage.ContextMenus(mock.Object);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(contextMenuResults.Count, 3);
|
Assert.AreEqual(contextMenuResults.Count, 3);
|
||||||
@@ -390,7 +389,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
List<ContextMenuResult> contextMenuResults = dummy_internetShortcut_app.ContextMenus(mock.Object);
|
List<ContextMenuResult> contextMenuResults = _dummyInternetShortcutApp.ContextMenus(mock.Object);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(contextMenuResults.Count, 2);
|
Assert.AreEqual(contextMenuResults.Count, 2);
|
||||||
@@ -406,7 +405,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
List<ContextMenuResult> contextMenuResults = chrome.ContextMenus(mock.Object);
|
List<ContextMenuResult> contextMenuResults = _chrome.ContextMenus(mock.Object);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(contextMenuResults.Count, 3);
|
Assert.AreEqual(contextMenuResults.Count, 3);
|
||||||
@@ -423,7 +422,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
mock.Setup(x => x.GetTranslation(It.IsAny<string>())).Returns(It.IsAny<string>());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
List<ContextMenuResult> contextMenuResults = cmd_run_command.ContextMenus(mock.Object);
|
List<ContextMenuResult> contextMenuResults = _cmdRunCommand.ContextMenus(mock.Object);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(contextMenuResults.Count, 3);
|
Assert.AreEqual(contextMenuResults.Count, 3);
|
||||||
@@ -440,11 +439,11 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
|||||||
StringMatcher.Instance = new StringMatcher();
|
StringMatcher.Instance = new StringMatcher();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = cmder_run_command.Result("cmder", mock.Object);
|
var result = _cmderRunCommand.Result("cmder", mock.Object);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsTrue(result.Title.Equals(cmder_run_command.Name, StringComparison.Ordinal));
|
Assert.IsTrue(result.Title.Equals(_cmderRunCommand.Name, StringComparison.Ordinal));
|
||||||
Assert.IsFalse(result.Title.Equals(cmder_run_command.Description, StringComparison.Ordinal));
|
Assert.IsFalse(result.Title.Equals(_cmderRunCommand.Description, StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class Win32ProgramRepositoryTest
|
public class Win32ProgramRepositoryTest
|
||||||
{
|
{
|
||||||
|
private readonly ProgramPluginSettings _settings = new ProgramPluginSettings();
|
||||||
|
private readonly string[] _pathsToWatch = new string[] { "location1", "location2" };
|
||||||
|
|
||||||
private List<IFileSystemWatcherWrapper> _fileSystemWatchers;
|
private List<IFileSystemWatcherWrapper> _fileSystemWatchers;
|
||||||
private ProgramPluginSettings _settings = new ProgramPluginSettings();
|
|
||||||
private string[] _pathsToWatch = new string[] { "location1", "location2" };
|
|
||||||
private List<Mock<IFileSystemWatcherWrapper>> _fileSystemMocks;
|
private List<Mock<IFileSystemWatcherWrapper>> _fileSystemMocks;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
@@ -41,7 +42,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
public void Win32RepositoryMustNotStoreDuplicatesWhileAddingItemsWithSameHashCode(string name, string exename, string fullPath, string description1, string description2)
|
public void Win32RepositoryMustNotStoreDuplicatesWhileAddingItemsWithSameHashCode(string name, string exename, string fullPath, string description1, string description2)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
|
|
||||||
Win32Program item1 = new Win32Program
|
Win32Program item1 = new Win32Program
|
||||||
{
|
{
|
||||||
@@ -60,55 +61,55 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_win32ProgramRepository.Add(item1);
|
win32ProgramRepository.Add(item1);
|
||||||
|
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
|
|
||||||
// To add an item with the same hashCode, ie, same name, exename and fullPath
|
// To add an item with the same hashCode, ie, same name, exename and fullPath
|
||||||
_win32ProgramRepository.Add(item2);
|
win32ProgramRepository.Add(item2);
|
||||||
|
|
||||||
// Assert, count still remains 1 because they are duplicate items
|
// Assert, count still remains 1 because they are duplicate items
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("path.appref-ms")]
|
[TestCase("path.appref-ms")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppCreatedForApprefAppsWhenCreatedEventIsRaised(string path)
|
public void Win32ProgramRepositoryMustCallOnAppCreatedForApprefAppsWhenCreatedEventIsRaised(string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.AreEqual(_win32ProgramRepository.ElementAt(0).AppType, 2);
|
Assert.AreEqual(win32ProgramRepository.ElementAt(0).AppType, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "path.appref-ms")]
|
[TestCase("directory", "path.appref-ms")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppDeletedForApprefAppsWhenDeletedEventIsRaised(string directory, string path)
|
public void Win32ProgramRepositoryMustCallOnAppDeletedForApprefAppsWhenDeletedEventIsRaised(string directory, string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
||||||
|
|
||||||
string fullPath = directory + "\\" + path;
|
string fullPath = directory + "\\" + path;
|
||||||
Win32Program item = Win32Program.GetAppFromPath(fullPath);
|
Win32Program item = Win32Program.GetAppFromPath(fullPath);
|
||||||
_win32ProgramRepository.Add(item);
|
win32ProgramRepository.Add(item);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 0);
|
Assert.AreEqual(win32ProgramRepository.Count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "oldpath.appref-ms", "newpath.appref-ms")]
|
[TestCase("directory", "oldpath.appref-ms", "newpath.appref-ms")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppRenamedForApprefAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
|
public void Win32ProgramRepositoryMustCallOnAppRenamedForApprefAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
|
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
|
||||||
|
|
||||||
string oldFullPath = directory + "\\" + oldpath;
|
string oldFullPath = directory + "\\" + oldpath;
|
||||||
@@ -116,22 +117,22 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
Win32Program olditem = Win32Program.GetAppFromPath(oldFullPath);
|
Win32Program olditem = Win32Program.GetAppFromPath(oldFullPath);
|
||||||
Win32Program newitem = Win32Program.GetAppFromPath(newFullPath);
|
Win32Program newitem = Win32Program.GetAppFromPath(newFullPath);
|
||||||
_win32ProgramRepository.Add(olditem);
|
win32ProgramRepository.Add(olditem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.IsTrue(_win32ProgramRepository.Contains(newitem));
|
Assert.IsTrue(win32ProgramRepository.Contains(newitem));
|
||||||
Assert.IsFalse(_win32ProgramRepository.Contains(olditem));
|
Assert.IsFalse(win32ProgramRepository.Contains(olditem));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("path.exe")]
|
[TestCase("path.exe")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppCreatedForExeAppsWhenCreatedEventIsRaised(string path)
|
public void Win32ProgramRepositoryMustCallOnAppCreatedForExeAppsWhenCreatedEventIsRaised(string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
||||||
|
|
||||||
// FileVersionInfo must be mocked for exe applications
|
// FileVersionInfo must be mocked for exe applications
|
||||||
@@ -143,15 +144,15 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.AreEqual(_win32ProgramRepository.ElementAt(0).AppType, 2);
|
Assert.AreEqual(win32ProgramRepository.ElementAt(0).AppType, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "path.exe")]
|
[TestCase("directory", "path.exe")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppDeletedForExeAppsWhenDeletedEventIsRaised(string directory, string path)
|
public void Win32ProgramRepositoryMustCallOnAppDeletedForExeAppsWhenDeletedEventIsRaised(string directory, string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
||||||
|
|
||||||
// FileVersionInfo must be mocked for exe applications
|
// FileVersionInfo must be mocked for exe applications
|
||||||
@@ -161,20 +162,20 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
string fullPath = directory + "\\" + path;
|
string fullPath = directory + "\\" + path;
|
||||||
Win32Program item = Win32Program.GetAppFromPath(fullPath);
|
Win32Program item = Win32Program.GetAppFromPath(fullPath);
|
||||||
_win32ProgramRepository.Add(item);
|
win32ProgramRepository.Add(item);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 0);
|
Assert.AreEqual(win32ProgramRepository.Count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "oldpath.appref-ms", "newpath.appref-ms")]
|
[TestCase("directory", "oldpath.appref-ms", "newpath.appref-ms")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppRenamedForExeAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
|
public void Win32ProgramRepositoryMustCallOnAppRenamedForExeAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
|
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
|
||||||
|
|
||||||
string oldFullPath = directory + "\\" + oldpath;
|
string oldFullPath = directory + "\\" + oldpath;
|
||||||
@@ -187,22 +188,22 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
Win32Program olditem = Win32Program.GetAppFromPath(oldFullPath);
|
Win32Program olditem = Win32Program.GetAppFromPath(oldFullPath);
|
||||||
Win32Program newitem = Win32Program.GetAppFromPath(newFullPath);
|
Win32Program newitem = Win32Program.GetAppFromPath(newFullPath);
|
||||||
_win32ProgramRepository.Add(olditem);
|
win32ProgramRepository.Add(olditem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.IsTrue(_win32ProgramRepository.Contains(newitem));
|
Assert.IsTrue(win32ProgramRepository.Contains(newitem));
|
||||||
Assert.IsFalse(_win32ProgramRepository.Contains(olditem));
|
Assert.IsFalse(win32ProgramRepository.Contains(olditem));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("path.url")]
|
[TestCase("path.url")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppChangedForUrlAppsWhenChangedEventIsRaised(string path)
|
public void Win32ProgramRepositoryMustCallOnAppChangedForUrlAppsWhenChangedEventIsRaised(string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Changed, "directory", path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Changed, "directory", path);
|
||||||
|
|
||||||
// File.ReadAllLines must be mocked for url applications
|
// File.ReadAllLines must be mocked for url applications
|
||||||
@@ -214,8 +215,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
_fileSystemMocks[0].Raise(m => m.Changed += null, e);
|
_fileSystemMocks[0].Raise(m => m.Changed += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.AreEqual(_win32ProgramRepository.ElementAt(0).AppType, 1); // Internet Shortcut Application
|
Assert.AreEqual(win32ProgramRepository.ElementAt(0).AppType, 1); // Internet Shortcut Application
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("path.url")]
|
[TestCase("path.url")]
|
||||||
@@ -224,7 +225,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
// We are handing internet shortcut apps using the Changed event instead
|
// We are handing internet shortcut apps using the Changed event instead
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
||||||
|
|
||||||
// File.ReadAllLines must be mocked for url applications
|
// File.ReadAllLines must be mocked for url applications
|
||||||
@@ -236,7 +237,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 0);
|
Assert.AreEqual(win32ProgramRepository.Count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("path.exe")]
|
[TestCase("path.exe")]
|
||||||
@@ -247,7 +248,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
// We are handing internet shortcut apps using the Changed event instead
|
// We are handing internet shortcut apps using the Changed event instead
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Changed, "directory", path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Changed, "directory", path);
|
||||||
|
|
||||||
// FileVersionInfo must be mocked for exe applications
|
// FileVersionInfo must be mocked for exe applications
|
||||||
@@ -264,14 +265,14 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
_fileSystemMocks[0].Raise(m => m.Changed += null, e);
|
_fileSystemMocks[0].Raise(m => m.Changed += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 0);
|
Assert.AreEqual(win32ProgramRepository.Count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "path.url")]
|
[TestCase("directory", "path.url")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppDeletedForUrlAppsWhenDeletedEventIsRaised(string directory, string path)
|
public void Win32ProgramRepositoryMustCallOnAppDeletedForUrlAppsWhenDeletedEventIsRaised(string directory, string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
||||||
|
|
||||||
// File.ReadAllLines must be mocked for url applications
|
// File.ReadAllLines must be mocked for url applications
|
||||||
@@ -281,20 +282,20 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
string fullPath = directory + "\\" + path;
|
string fullPath = directory + "\\" + path;
|
||||||
Win32Program item = Win32Program.GetAppFromPath(fullPath);
|
Win32Program item = Win32Program.GetAppFromPath(fullPath);
|
||||||
_win32ProgramRepository.Add(item);
|
win32ProgramRepository.Add(item);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 0);
|
Assert.AreEqual(win32ProgramRepository.Count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "oldpath.url", "newpath.url")]
|
[TestCase("directory", "oldpath.url", "newpath.url")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppRenamedForUrlAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
|
public void Win32ProgramRepositoryMustCallOnAppRenamedForUrlAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
|
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
|
||||||
|
|
||||||
// File.ReadAllLines must be mocked for url applications
|
// File.ReadAllLines must be mocked for url applications
|
||||||
@@ -307,22 +308,22 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
Win32Program olditem = Win32Program.GetAppFromPath(oldFullPath);
|
Win32Program olditem = Win32Program.GetAppFromPath(oldFullPath);
|
||||||
Win32Program newitem = Win32Program.GetAppFromPath(newFullPath);
|
Win32Program newitem = Win32Program.GetAppFromPath(newFullPath);
|
||||||
_win32ProgramRepository.Add(olditem);
|
win32ProgramRepository.Add(olditem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.IsTrue(_win32ProgramRepository.Contains(newitem));
|
Assert.IsTrue(win32ProgramRepository.Contains(newitem));
|
||||||
Assert.IsFalse(_win32ProgramRepository.Contains(olditem));
|
Assert.IsFalse(win32ProgramRepository.Contains(olditem));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("path.lnk")]
|
[TestCase("path.lnk")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppCreatedForLnkAppsWhenCreatedEventIsRaised(string path)
|
public void Win32ProgramRepositoryMustCallOnAppCreatedForLnkAppsWhenCreatedEventIsRaised(string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
||||||
|
|
||||||
// ShellLinkHelper must be mocked for lnk applications
|
// ShellLinkHelper must be mocked for lnk applications
|
||||||
@@ -334,15 +335,15 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.AreEqual(_win32ProgramRepository.ElementAt(0).AppType, 2);
|
Assert.AreEqual(win32ProgramRepository.ElementAt(0).AppType, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "path.lnk")]
|
[TestCase("directory", "path.lnk")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppDeletedForLnkAppsWhenDeletedEventIsRaised(string directory, string path)
|
public void Win32ProgramRepositoryMustCallOnAppDeletedForLnkAppsWhenDeletedEventIsRaised(string directory, string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Deleted, directory, path);
|
||||||
|
|
||||||
// ShellLinkHelper must be mocked for lnk applications
|
// ShellLinkHelper must be mocked for lnk applications
|
||||||
@@ -359,24 +360,24 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
FullPath = "directory\\path.exe",
|
FullPath = "directory\\path.exe",
|
||||||
LnkResolvedPath = "directory\\path.lnk", // This must be equal for lnk applications
|
LnkResolvedPath = "directory\\path.lnk", // This must be equal for lnk applications
|
||||||
};
|
};
|
||||||
_win32ProgramRepository.Add(item);
|
win32ProgramRepository.Add(item);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
_fileSystemMocks[0].Raise(m => m.Deleted += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 0);
|
Assert.AreEqual(win32ProgramRepository.Count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("directory", "oldpath.lnk", "path.lnk")]
|
[TestCase("directory", "oldpath.lnk", "path.lnk")]
|
||||||
public void Win32ProgramRepositoryMustCallOnAppRenamedForLnkAppsWhenRenamedEventIsRaised(string directory, string oldpath, string path)
|
public void Win32ProgramRepositoryMustCallOnAppRenamedForLnkAppsWhenRenamedEventIsRaised(string directory, string oldpath, string path)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32Program>>("Win32"), _settings, _pathsToWatch);
|
||||||
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, path, oldpath);
|
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, path, oldpath);
|
||||||
|
|
||||||
string oldFullPath = directory + "\\" + oldpath;
|
string oldFullPath = directory + "\\" + oldpath;
|
||||||
string FullPath = directory + "\\" + path;
|
string fullPath = directory + "\\" + path;
|
||||||
|
|
||||||
// ShellLinkHelper must be mocked for lnk applications
|
// ShellLinkHelper must be mocked for lnk applications
|
||||||
var mockShellLink = new Mock<IShellLinkHelper>();
|
var mockShellLink = new Mock<IShellLinkHelper>();
|
||||||
@@ -388,25 +389,25 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
{
|
{
|
||||||
Name = "oldpath",
|
Name = "oldpath",
|
||||||
ExecutableName = path,
|
ExecutableName = path,
|
||||||
FullPath = FullPath,
|
FullPath = fullPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
Win32Program newitem = new Win32Program
|
Win32Program newitem = new Win32Program
|
||||||
{
|
{
|
||||||
Name = "path",
|
Name = "path",
|
||||||
ExecutableName = path,
|
ExecutableName = path,
|
||||||
FullPath = FullPath,
|
FullPath = fullPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
_win32ProgramRepository.Add(olditem);
|
win32ProgramRepository.Add(olditem);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
_fileSystemMocks[0].Raise(m => m.Renamed += null, e);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(_win32ProgramRepository.Count(), 1);
|
Assert.AreEqual(win32ProgramRepository.Count(), 1);
|
||||||
Assert.IsTrue(_win32ProgramRepository.Contains(newitem));
|
Assert.IsTrue(win32ProgramRepository.Contains(newitem));
|
||||||
Assert.IsFalse(_win32ProgramRepository.Contains(olditem));
|
Assert.IsFalse(win32ProgramRepository.Contains(olditem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,9 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
var namespaces = XmlNamespaces(path);
|
var namespaces = XmlNamespaces(path);
|
||||||
InitPackageVersion(namespaces);
|
InitPackageVersion(namespaces);
|
||||||
|
|
||||||
IStream stream;
|
|
||||||
const uint noAttribute = 0x80;
|
const uint noAttribute = 0x80;
|
||||||
const Stgm exclusiveRead = Stgm.Read;
|
const Stgm exclusiveRead = Stgm.Read;
|
||||||
var hResult = NativeMethods.SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out stream);
|
var hResult = NativeMethods.SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out IStream stream);
|
||||||
|
|
||||||
if (hResult == Hresult.Ok)
|
if (hResult == Hresult.Ok)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -193,14 +193,13 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
private async void Launch(IPublicAPI api)
|
private async void Launch(IPublicAPI api)
|
||||||
{
|
{
|
||||||
var appManager = new ApplicationActivationHelper.ApplicationActivationManager();
|
var appManager = new ApplicationActivationHelper.ApplicationActivationManager();
|
||||||
uint unusedPid;
|
|
||||||
const string noArgs = "";
|
const string noArgs = "";
|
||||||
const ApplicationActivationHelper.ActivateOptions noFlags = ApplicationActivationHelper.ActivateOptions.None;
|
const ApplicationActivationHelper.ActivateOptions noFlags = ApplicationActivationHelper.ActivateOptions.None;
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
appManager.ActivateApplication(UserModelId, noArgs, noFlags, out unusedPid);
|
appManager.ActivateApplication(UserModelId, noArgs, noFlags, out uint unusedPid);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user