Skip to content

Commit fd26f4e

Browse files
authored
Merge pull request #8 from alx9r/implement-shortcut
Implement shortcut
2 parents e3680a1 + 9005a1b commit fd26f4e

28 files changed

+1859
-716
lines changed

Functions/icon.Tests.ps1

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Import-Module WindowsShell -Force
2+
3+
InModuleScope WindowsShell {
4+
Describe 'Get-IconReferencePath' {
5+
Mock Get-StockIconReferencePath -Verifiable
6+
Context 'StockIconName' {
7+
Mock Get-StockIconReferencePath { 'stock icon reference path' } -Verifiable
8+
It 'returns result based on StockIconName' {
9+
$splat = @{
10+
StockIconName = 'DocumentNotAssociated'
11+
IconFilePath = ''
12+
IconResourceId = 0
13+
}
14+
$r = Get-IconReferencePath @splat
15+
$r | Should be 'stock icon reference path'
16+
}
17+
It 'correctly invokes functions' {
18+
Assert-MockCalled Get-StockIconReferencePath 1 {
19+
$StockIconName -eq 'DocumentNotAssociated'
20+
}
21+
}
22+
}
23+
Context 'IconFilePath' {
24+
It 'returns result based on IconFilePath' {
25+
$splat = @{
26+
StockIconName = ''
27+
IconFilePath = 'c:\Windows\calc.exe'
28+
IconResourceId = 1
29+
}
30+
$r = Get-IconReferencePath @splat
31+
$r | Should be 'c:\Windows\calc.exe,1'
32+
}
33+
It 'correctly invokes functions' {
34+
Assert-MockCalled Get-StockIconReferencePath 0 -Exactly
35+
}
36+
}
37+
Context 'neither' {
38+
It 'returns nothing' {
39+
$splat = @{
40+
StockIconName = ''
41+
IconFilePath = ''
42+
IconResourceId = 0
43+
}
44+
$r = Get-IconReferencePath @splat
45+
$r | Should beNullOrEmpty
46+
}
47+
}
48+
}
49+
}

Functions/icon.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function Get-IconReferencePath
2+
{
3+
[CmdletBinding()]
4+
param
5+
(
6+
[string]
7+
$StockIconName,
8+
9+
[string]
10+
$IconFilePath,
11+
12+
[int]
13+
$IconResourceId
14+
)
15+
process
16+
{
17+
# return based on the StockIconName
18+
if ( $StockIconName -and $StockIconName -ne 'DoNotSet' )
19+
{
20+
return Get-StockIconReferencePath $StockIconName
21+
}
22+
23+
# return based on IconFilePath
24+
if ( $IconFilePath )
25+
{
26+
return "$IconFilePath,$IconResourceId"
27+
}
28+
}
29+
}

Functions/loadTypes.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
@(
33
'shellLibraryType.ps1'
4+
'shellLibraryFolderType.ps1'
45
'stockIconInfoType.ps1'
6+
'shortcutType.ps1'
57
) |
68
% { . "$($PSCommandPath | Split-Path -Parent)\$_" }

0 commit comments

Comments
 (0)