File tree Expand file tree Collapse file tree
test/powershell/Language/Classes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -410,6 +410,39 @@ Describe 'ValidateSet support a dynamically generated set' -Tag "CI" {
410410 Get-TestValidateSetPS6 - Param1 " AnyTestString" - ErrorAction Stop
411411 } | ShouldBeErrorId " TypeNotFound"
412412 }
413+
414+ It ' IValidateSetValuesGenerator works in PowerShell module' {
415+ $moduleFile = Join-Path $TestDrive - ChildPath " Test-Module-$ ( (New-Guid ).Guid) .psm1"
416+ $module = @'
417+ class ValidateSetTest : System.Management.Automation.IValidateSetValuesGenerator
418+ {
419+ [string[]] GetValidValues()
420+ {
421+ return 'Hello', 'World'
422+ }
423+ }
424+
425+ function Test-ValidateSet
426+ {
427+ [CmdletBinding()]
428+ param (
429+ [Parameter(Mandatory = $true)]
430+ [ValidateSet([ValidateSetTest])]
431+ [string[]]
432+ $Item
433+ )
434+ $Item
435+ }
436+ '@
437+ Set-Content - Path $moduleFile - Value $module - Force
438+
439+ try {
440+ Import-Module - Name $moduleFile - Force
441+ Test-ValidateSet ' Hello' | Should Be ' Hello'
442+ } finally {
443+ Remove-Module - Name $moduleFile - Force
444+ }
445+ }
413446 }
414447
415448 Context ' CachedValidValuesGeneratorBase class tests' {
You can’t perform that action at this time.
0 commit comments