Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Functions/icon.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Import-Module WindowsShell -Force

InModuleScope WindowsShell {
Describe 'Get-IconReferencePath' {
Mock Get-StockIconReferencePath -Verifiable
Context 'StockIconName' {
Mock Get-StockIconReferencePath { 'stock icon reference path' } -Verifiable
It 'returns result based on StockIconName' {
$splat = @{
StockIconName = 'DocumentNotAssociated'
IconFilePath = ''
IconResourceId = 0
}
$r = Get-IconReferencePath @splat
$r | Should be 'stock icon reference path'
}
It 'correctly invokes functions' {
Assert-MockCalled Get-StockIconReferencePath 1 {
$StockIconName -eq 'DocumentNotAssociated'
}
}
}
Context 'IconFilePath' {
It 'returns result based on IconFilePath' {
$splat = @{
StockIconName = ''
IconFilePath = 'c:\Windows\calc.exe'
IconResourceId = 1
}
$r = Get-IconReferencePath @splat
$r | Should be 'c:\Windows\calc.exe,1'
}
It 'correctly invokes functions' {
Assert-MockCalled Get-StockIconReferencePath 0 -Exactly
}
}
Context 'neither' {
It 'returns nothing' {
$splat = @{
StockIconName = ''
IconFilePath = ''
IconResourceId = 0
}
$r = Get-IconReferencePath @splat
$r | Should beNullOrEmpty
}
}
}
}
29 changes: 29 additions & 0 deletions Functions/icon.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function Get-IconReferencePath
{
[CmdletBinding()]
param
(
[string]
$StockIconName,

[string]
$IconFilePath,

[int]
$IconResourceId
)
process
{
# return based on the StockIconName
if ( $StockIconName -and $StockIconName -ne 'DoNotSet' )
{
return Get-StockIconReferencePath $StockIconName
}

# return based on IconFilePath
if ( $IconFilePath )
{
return "$IconFilePath,$IconResourceId"
}
}
}
2 changes: 2 additions & 0 deletions Functions/loadTypes.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

@(
'shellLibraryType.ps1'
'shellLibraryFolderType.ps1'
'stockIconInfoType.ps1'
'shortcutType.ps1'
) |
% { . "$($PSCommandPath | Split-Path -Parent)\$_" }
Loading