Skip to content

Commit 063a2d0

Browse files
committed
Add tests for validating parameter sets in Get-SqlDscCompatibilityLevel
1 parent 77db78a commit 063a2d0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Unit/Public/Get-SqlDscCompatibilityLevel.Tests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,29 @@ AfterAll {
5050
}
5151

5252
Describe 'Get-SqlDscCompatibilityLevel' -Tag 'Public' {
53+
Context 'When validating parameter sets' {
54+
It 'Should have the correct parameters in parameter set <ExpectedParameterSetName>' -ForEach @(
55+
@{
56+
ExpectedParameterSetName = 'ServerObject'
57+
ExpectedParameters = '-ServerObject <Server> [<CommonParameters>]'
58+
}
59+
@{
60+
ExpectedParameterSetName = 'Version'
61+
ExpectedParameters = '-Version <Version> [<CommonParameters>]'
62+
}
63+
) {
64+
$result = (Get-Command -Name 'Get-SqlDscCompatibilityLevel').ParameterSets |
65+
Where-Object -FilterScript { $_.Name -eq $ExpectedParameterSetName } |
66+
Select-Object -Property @(
67+
@{ Name = 'ParameterSetName'; Expression = { $_.Name } },
68+
@{ Name = 'ParameterListAsString'; Expression = { $_.ToString() } }
69+
)
70+
71+
$result.ParameterSetName | Should -Be $ExpectedParameterSetName
72+
$result.ParameterListAsString | Should -Be $ExpectedParameters
73+
}
74+
}
75+
5376
Context 'When getting compatibility levels for a server object' {
5477
BeforeAll {
5578
$mockServerObject = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Server'

0 commit comments

Comments
 (0)