File tree Expand file tree Collapse file tree 4 files changed +40
-2
lines changed
Expand file tree Collapse file tree 4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ function Disable-SqlDscRsSecureConnection
123123 {
124124 $errorMessage = $script :localizedData.Disable_SqlDscRsSecureConnection_FailedToDisable -f $instanceName , $_.Exception.Message
125125
126- $errorRecord = New-ErrorRecord - Exception (New-InvalidOperationException - Message $errorMessage ) - ErrorId ' DSRSSC0001' - ErrorCategory ' InvalidOperation' - TargetObject $Configuration
126+ $errorRecord = New-ErrorRecord - Exception (New-InvalidOperationException - Message $errorMessage - PassThru ) - ErrorId ' DSRSSC0001' - ErrorCategory ' InvalidOperation' - TargetObject $Configuration
127127
128128 $PSCmdlet.ThrowTerminatingError ($errorRecord )
129129 }
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ function Enable-SqlDscRsSecureConnection
127127 {
128128 $errorMessage = $script :localizedData.Enable_SqlDscRsSecureConnection_FailedToEnable -f $instanceName , $_.Exception.Message
129129
130- $errorRecord = New-ErrorRecord - Exception (New-InvalidOperationException - Message $errorMessage ) - ErrorId ' ESRSSC0001' - ErrorCategory ' InvalidOperation' - TargetObject $Configuration
130+ $errorRecord = New-ErrorRecord - Exception (New-InvalidOperationException - Message $errorMessage - PassThru ) - ErrorId ' ESRSSC0001' - ErrorCategory ' InvalidOperation' - TargetObject $Configuration
131131
132132 $PSCmdlet.ThrowTerminatingError ($errorRecord )
133133 }
Original file line number Diff line number Diff line change @@ -79,6 +79,25 @@ Describe 'Disable-SqlDscRsSecureConnection' {
7979 }
8080 }
8181
82+ Context ' When validating parameter sets' {
83+ It ' Should have the correct parameters in parameter set <ExpectedParameterSetName>' - ForEach @ (
84+ @ {
85+ ExpectedParameterSetName = ' __AllParameterSets'
86+ ExpectedParameters = ' [-Configuration] <Object> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
87+ }
88+ ) {
89+ $result = (Get-Command - Name ' Disable-SqlDscRsSecureConnection' ).ParameterSets |
90+ Where-Object - FilterScript { $_.Name -eq $ExpectedParameterSetName } |
91+ Select-Object - Property @ (
92+ @ { Name = ' ParameterSetName' ; Expression = { $_.Name } },
93+ @ { Name = ' ParameterListAsString' ; Expression = { $_.ToString () } }
94+ )
95+
96+ $result.ParameterSetName | Should - Be $ExpectedParameterSetName
97+ $result.ParameterListAsString | Should - Be $ExpectedParameters
98+ }
99+ }
100+
82101 Context ' When disabling secure connection successfully' {
83102 BeforeAll {
84103 $mockCimInstance = [PSCustomObject ] @ {
Original file line number Diff line number Diff line change @@ -79,6 +79,25 @@ Describe 'Enable-SqlDscRsSecureConnection' {
7979 }
8080 }
8181
82+ Context ' When validating parameter sets' {
83+ It ' Should have the correct parameters in parameter set <ExpectedParameterSetName>' - ForEach @ (
84+ @ {
85+ ExpectedParameterSetName = ' __AllParameterSets'
86+ ExpectedParameters = ' [-Configuration] <Object> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
87+ }
88+ ) {
89+ $result = (Get-Command - Name ' Enable-SqlDscRsSecureConnection' ).ParameterSets |
90+ Where-Object - FilterScript { $_.Name -eq $ExpectedParameterSetName } |
91+ Select-Object - Property @ (
92+ @ { Name = ' ParameterSetName' ; Expression = { $_.Name } },
93+ @ { Name = ' ParameterListAsString' ; Expression = { $_.ToString () } }
94+ )
95+
96+ $result.ParameterSetName | Should - Be $ExpectedParameterSetName
97+ $result.ParameterListAsString | Should - Be $ExpectedParameters
98+ }
99+ }
100+
82101 Context ' When enabling secure connection successfully' {
83102 BeforeAll {
84103 $mockCimInstance = [PSCustomObject ] @ {
You can’t perform that action at this time.
0 commit comments