@@ -214,7 +214,7 @@ should be written to cover all possible scenarios and code paths, ensuring
214214that both edge cases and common use cases are tested.
215215
216216All public commands should always have a test to validate parameter sets
217- using this template:
217+ using this template. For commands with a single parameter set :
218218
219219``` powershell
220220It 'Should have the correct parameters in parameter set <MockParameterSetName>' -ForEach @(
@@ -243,6 +243,53 @@ It 'Should have the correct parameters in parameter set <MockParameterSetName>'
243243}
244244```
245245
246+ For commands with multiple parameter sets, use this pattern:
247+
248+ ``` powershell
249+ It 'Should have the correct parameters in parameter set <MockParameterSetName>' -ForEach @(
250+ @{
251+ MockParameterSetName = 'ParameterSet1'
252+ MockExpectedParameters = '-ServerObject <Server> -Name <string> -Parameter1 <string> [<CommonParameters>]'
253+ }
254+ @{
255+ MockParameterSetName = 'ParameterSet2'
256+ MockExpectedParameters = '-ServerObject <Server> -Name <string> -Parameter2 <uint> [<CommonParameters>]'
257+ }
258+ ) {
259+ $result = (Get-Command -Name 'CommandName').ParameterSets |
260+ Where-Object -FilterScript {
261+ $_.Name -eq $mockParameterSetName
262+ } |
263+ Select-Object -Property @(
264+ @{
265+ Name = 'ParameterSetName'
266+ Expression = { $_.Name }
267+ },
268+ @{
269+ Name = 'ParameterListAsString'
270+ Expression = { $_.ToString() }
271+ }
272+ )
273+
274+ $result.ParameterSetName | Should -Be $MockParameterSetName
275+ $result.ParameterListAsString | Should -Be $MockExpectedParameters
276+ }
277+ ```
278+
279+ All public commands should also include tests to validate parameter properties:
280+
281+ ``` powershell
282+ It 'Should have ParameterName as a mandatory parameter' {
283+ $parameterInfo = (Get-Command -Name 'CommandName').Parameters['ParameterName']
284+ $parameterInfo.Attributes.Mandatory | Should -Contain $true
285+ }
286+
287+ It 'Should accept ParameterName from pipeline' {
288+ $parameterInfo = (Get-Command -Name 'CommandName').Parameters['ParameterName']
289+ $parameterInfo.Attributes.ValueFromPipeline | Should -Contain $true
290+ }
291+ ```
292+
246293The ` BeforeAll ` block should be used to set up any necessary test data or mocking
247294
248295Use localized strings in the tests only when necessary. You can assign the
0 commit comments