forked from dataplat/dbatools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisconnect-DbaInstance.Tests.ps1
45 lines (39 loc) · 1.32 KB
/
Disconnect-DbaInstance.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
param(
$ModuleName = "dbatools",
$PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults
)
Describe "Disconnect-DbaInstance" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Disconnect-DbaInstance
$expected = $TestConfig.CommonParameters
$expected += @(
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
It "Should have exactly the number of expected parameters ($($expected.Count))" {
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Describe "Disconnect-DbaInstance" -Tag "IntegrationTests" {
BeforeAll {
$null = Connect-DbaInstance -SqlInstance $TestConfig.Instance1
}
Context "When disconnecting a server" {
BeforeAll {
$results = Get-DbaConnectedInstance | Disconnect-DbaInstance
}
It "Returns results" {
$results | Should -Not -BeNullOrEmpty
}
}
}