Skip to content

Commit 922046f

Browse files
committed
Update Get-SqlDscServerProtocol tests to suppress result assignment and enhance pipeline parameter validation
1 parent 2d78fe4 commit 922046f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Describe 'Get-SqlDscServerProtocol' -Tag 'Public' {
199199
return 'LocalComputer'
200200
}
201201

202-
$result = Get-SqlDscServerProtocol -ServerName 'TestServer' -InstanceName 'MSSQLSERVER' -ProtocolName 'TcpIp'
202+
$null = Get-SqlDscServerProtocol -ServerName 'TestServer' -InstanceName 'MSSQLSERVER' -ProtocolName 'TcpIp'
203203

204204
Should -Invoke -CommandName Get-SqlDscManagedComputerInstance -ParameterFilter {
205205
$ServerName -eq 'TestServer'
@@ -211,7 +211,7 @@ Describe 'Get-SqlDscServerProtocol' -Tag 'Public' {
211211
return 'LocalComputer'
212212
}
213213

214-
$result = Get-SqlDscServerProtocol -InstanceName 'MSSQLSERVER' -ProtocolName 'TcpIp'
214+
$null = Get-SqlDscServerProtocol -InstanceName 'MSSQLSERVER' -ProtocolName 'TcpIp'
215215

216216
Should -Invoke -CommandName Get-SqlDscManagedComputerInstance -ParameterFilter {
217217
$ServerName -eq 'LocalComputer'
@@ -223,6 +223,10 @@ Describe 'Get-SqlDscServerProtocol' -Tag 'Public' {
223223

224224
$result | Should -Not -BeNullOrEmpty
225225
$result.Name | Should -Be 'Tcp'
226+
227+
Should -Invoke -CommandName Get-SqlDscManagedComputerInstance -ParameterFilter {
228+
$InstanceName -eq 'SQL2019'
229+
} -Exactly -Times 1 -Scope It
226230
}
227231
}
228232

@@ -411,12 +415,12 @@ Describe 'Get-SqlDscServerProtocol' -Tag 'Public' {
411415

412416
It 'Should have ManagedComputerObject as a pipeline parameter' {
413417
$parameterInfo = (Get-Command -Name 'Get-SqlDscServerProtocol').Parameters['ManagedComputerObject']
414-
$parameterInfo.Attributes.ValueFromPipeline | Should -BeTrue
418+
$parameterInfo.Attributes.ValueFromPipeline | Should -Not -Contain $false
415419
}
416420

417421
It 'Should have ManagedComputerInstanceObject as a pipeline parameter' {
418422
$parameterInfo = (Get-Command -Name 'Get-SqlDscServerProtocol').Parameters['ManagedComputerInstanceObject']
419-
$parameterInfo.Attributes.ValueFromPipeline | Should -BeTrue
423+
$parameterInfo.Attributes.ValueFromPipeline | Should -Not -Contain $false
420424
}
421425
}
422426
}

0 commit comments

Comments
 (0)