Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,39 @@ Describe 'ValidateSet support a dynamically generated set' -Tag "CI" {
Get-TestValidateSetPS6 -Param1 "AnyTestString" -ErrorAction Stop
} | ShouldBeErrorId "TypeNotFound"
}

It 'IValidateSetValuesGenerator works in PowerShell module' {
$moduleFile = Join-Path $TestDrive -ChildPath "Test-Module-$((New-Guid).Guid).psm1"
$module = @'
class ValidateSetTest : System.Management.Automation.IValidateSetValuesGenerator
{
[string[]] GetValidValues()
{
return 'Hello', 'World'
}
}

function Test-ValidateSet
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateSet([ValidateSetTest])]
[string[]]
$Item
)
$Item
}
'@
Set-Content -Path $moduleFile -Value $module -Force

try {
Import-Module -Name $moduleFile -Force
Test-ValidateSet 'Hello' | Should Be 'Hello'
} finally {
Remove-Module -Name $moduleFile -Force
}
}
}

Context 'CachedValidValuesGeneratorBase class tests' {
Expand Down