-
-
Notifications
You must be signed in to change notification settings - Fork 831
/
Copy pathAdd-DbaPfDataCollectorCounter.Tests.ps1
66 lines (57 loc) · 2.23 KB
/
Add-DbaPfDataCollectorCounter.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
param(
$ModuleName = "dbatools",
$PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults
)
Describe "Add-DbaPfDataCollectorCounter" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaPfDataCollectorCounter
$expected = $TestConfig.CommonParameters
$expected += @(
"ComputerName",
"Credential",
"CollectorSet",
"Collector",
"Counter",
"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 "Add-DbaPfDataCollectorCounter" -Tag "IntegrationTests" {
BeforeAll {
$PSDefaultParameterValues['*:Confirm'] = $false
}
BeforeEach {
$null = Get-DbaPfDataCollectorSetTemplate -Template 'Long Running Queries' |
Import-DbaPfDataCollectorSetTemplate |
Get-DbaPfDataCollector |
Get-DbaPfDataCollectorCounter -Counter '\LogicalDisk(*)\Avg. Disk Queue Length' |
Remove-DbaPfDataCollectorCounter
$results = Get-DbaPfDataCollectorSet -CollectorSet 'Long Running Queries' | Get-DbaPfDataCollector |
Add-DbaPfDataCollectorCounter -Counter '\LogicalDisk(*)\Avg. Disk Queue Length'
}
AfterAll {
$null = Get-DbaPfDataCollectorSet -CollectorSet 'Long Running Queries' |
Remove-DbaPfDataCollectorSet
}
Context "When adding a counter to a data collector" {
It "Returns the correct DataCollectorSet" {
$results.DataCollectorSet | Should -Be 'Long Running Queries'
}
It "Returns the correct counter name" {
$results.Name | Should -Be '\LogicalDisk(*)\Avg. Disk Queue Length'
}
}
}