Skip to content

Commit 51ac093

Browse files
committed
Add tests for parameter sets in Disable-SqlDscDatabaseSnapshotIsolation and Enable-SqlDscDatabaseSnapshotIsolation
1 parent 37d57c7 commit 51ac093

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/Unit/Public/Disable-SqlDscDatabaseSnapshotIsolation.Tests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ AfterAll {
5858
}
5959

6060
Describe 'Disable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
61+
Context 'When the command has proper parameter sets' {
62+
It 'Should have the correct parameters in parameter set <ExpectedParameterSetName>' -ForEach @(
63+
@{
64+
ExpectedParameterSetName = 'ServerObjectSet'
65+
ExpectedParameters = '-ServerObject <Server> -Name <string> [-Refresh] [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
66+
}
67+
@{
68+
ExpectedParameterSetName = 'DatabaseObjectSet'
69+
ExpectedParameters = '-DatabaseObject <Database> [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
70+
}
71+
) {
72+
$result = (Get-Command -Name 'Disable-SqlDscDatabaseSnapshotIsolation').ParameterSets |
73+
Where-Object -FilterScript { $_.Name -eq $ExpectedParameterSetName } |
74+
Select-Object -Property @(
75+
@{ Name = 'ParameterSetName'; Expression = { $_.Name } },
76+
@{ Name = 'ParameterListAsString'; Expression = { $_.ToString() } }
77+
)
78+
79+
$result.ParameterSetName | Should -Be $ExpectedParameterSetName
80+
$result.ParameterListAsString | Should -Be $ExpectedParameters
81+
}
82+
}
83+
6184
Context 'When disabling snapshot isolation using ServerObject and Name' {
6285
BeforeAll {
6386
$mockDatabaseObject = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Database'

tests/Unit/Public/Enable-SqlDscDatabaseSnapshotIsolation.Tests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ AfterAll {
5858
}
5959

6060
Describe 'Enable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
61+
Context 'When the command has proper parameter sets' {
62+
It 'Should have the correct parameters in parameter set <ExpectedParameterSetName>' -ForEach @(
63+
@{
64+
ExpectedParameterSetName = 'ServerObjectSet'
65+
ExpectedParameters = '-ServerObject <Server> -Name <string> [-Refresh] [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
66+
}
67+
@{
68+
ExpectedParameterSetName = 'DatabaseObjectSet'
69+
ExpectedParameters = '-DatabaseObject <Database> [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
70+
}
71+
) {
72+
$result = (Get-Command -Name 'Enable-SqlDscDatabaseSnapshotIsolation').ParameterSets |
73+
Where-Object -FilterScript { $_.Name -eq $ExpectedParameterSetName } |
74+
Select-Object -Property @(
75+
@{ Name = 'ParameterSetName'; Expression = { $_.Name } },
76+
@{ Name = 'ParameterListAsString'; Expression = { $_.ToString() } }
77+
)
78+
79+
$result.ParameterSetName | Should -Be $ExpectedParameterSetName
80+
$result.ParameterListAsString | Should -Be $ExpectedParameters
81+
}
82+
}
83+
6184
Context 'When enabling snapshot isolation using ServerObject and Name' {
6285
BeforeAll {
6386
$mockDatabaseObject = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Database'

0 commit comments

Comments
 (0)