[PTRun][Program]Fix bug when renaming url shortcut (#17184)

* [PTRun][Program]Fix bug when renaming url shortcut

* Try to use the old full path for old app removal

* Guard against links to nowhere

* Fix test to have link point to existing location

* Update src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Fix nit.

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
This commit is contained in:
Jaime Bernardo
2022-03-25 10:08:10 +00:00
committed by GitHub
parent 559a0442d8
commit 80e9fc0c43
3 changed files with 23 additions and 11 deletions

View File

@@ -352,10 +352,11 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
string oldFullPath = directory + "\\" + oldpath;
string fullPath = directory + "\\" + path;
string linkingTo = Directory.GetCurrentDirectory();
// ShellLinkHelper must be mocked for lnk applications
var mockShellLink = new Mock<IShellLinkHelper>();
mockShellLink.Setup(m => m.RetrieveTargetPath(It.IsAny<string>())).Returns(string.Empty);
mockShellLink.Setup(m => m.RetrieveTargetPath(It.IsAny<string>())).Returns(linkingTo);
Win32Program.ShellLinkHelper = mockShellLink.Object;
// old item and new item are the actual items when they are in existence
@@ -363,14 +364,14 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
{
Name = "oldpath",
ExecutableName = oldpath,
FullPath = fullPath,
FullPath = linkingTo,
};
Win32Program newitem = new Win32Program
{
Name = "path",
ExecutableName = path,
FullPath = fullPath,
FullPath = linkingTo,
};
win32ProgramRepository.Add(olditem);