diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Service.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Service.Tests.ps1 index ee8aa972d3..be01791419 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Service.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Service.Tests.ps1 @@ -13,7 +13,7 @@ } $testCases = - @{ data = $null; value = 'null' }, + @{ data = $null ; value = 'null' }, @{ data = [String]::Empty; value = 'empty string' } Context 'Check null or empty value to the -Name parameter' { @@ -28,6 +28,7 @@ } } } + Context 'Check null or empty value to the -Name parameter via pipeline' { It 'Should throw if is passed through pipeline to -Name parameter' -TestCases $testCases { param($data) @@ -40,4 +41,53 @@ } } } + + It "GetServiceCommand can be used as API for '' with ''" -TestCases @( + @{ parameter = "DisplayName" ; value = "foo" }, + @{ parameter = "Include" ; value = "foo","bar" }, + @{ parameter = "Exclude" ; value = "bar","foo" }, + @{ parameter = "InputObject" ; script = { Get-Service | Select-Object -First 1 } }, + @{ parameter = "Name" ; value = "foo","bar" }, + @{ parameter = "ComputerName"; value = "bar","foo" } + ) { + param($parameter, $value, $script) + if ($script -ne $null) { + $value = & $script + } + + $getservicecmd = [Microsoft.PowerShell.Commands.GetServiceCommand]::new() + $getservicecmd.$parameter = $value + $getservicecmd.$parameter | Should Be $value + } + + It "Get-Service filtering works for '