-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerChart.Tests.ps1
More file actions
86 lines (85 loc) · 2.61 KB
/
PowerChart.Tests.ps1
File metadata and controls
86 lines (85 loc) · 2.61 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
switch ($PSVersionTable.PSVersion.Major) {
5 {
Import-Module $PSScriptRoot\..\bin\Debug\PowerChart.psd1
Update-TypeData -AppendPath $PSScriptRoot\..\bin\Debug\PowerChart.Types.ps1xml
}
7 {Import-Module $PSScriptRoot\..\bin\Debug\PowerChart.psd1}
default {Import-Module $PSScriptRoot\..\bin\Debug\PowerChart.psd1}
}
Describe "PowerChart API" {
It "Shows Chart" {
$chart = New-Chart
Show-Chart -Chart $chart
$chart.Dialog.Join()
}
It "Shows Points" {
$chart = New-Chart
$chart.Title = 'Shows Points'
$chart.XAxisLabel = 'time'
$chart.YAxisLabel = 'Energy'
$chart.BackColor = 'Cyan'
$chart.AxisColor = 'LimeGreen'
Add-Scatter -Chart $chart -XCoordinate 10 -YCoordinate 50 -Color Red
Add-Scatter -Chart $chart -XCoordinate 20 -YCoordinate 90 -Color Red -Size 5
Add-Scatter -Chart $chart -XCoordinate 30 -YCoordinate 50 -Color Red -Size 10.5
$chart.YMin = 0
$chart.YMax = 100
Show-Chart -Chart $chart
$chart.Dialog.Join()
}
It "Draws a Scatter Chart" {
$chart = New-Chart
$chart.Title = 'Get-Process (scatter)'
$chart.XAxisLabel = 'Process ID'
$chart.YAxisLabel = 'CPU'
Get-Process | Add-Scatter -Chart $chart -XProperty Id -YProperty CPU -Color Red -ErrorAction SilentlyContinue
Show-Chart -Chart $chart
$chart.Dialog.Join()
}
It "Draws multiple Scatter" {
$chart = New-Chart
$chart.Title = 'Get-Process (multiple)'
$chart.XAxisLabel = 'Process ID'
$chart.YAxisLabel = 'CPU/ID'
$processes = Get-Process
$processes | Add-Scatter -Chart $chart -XProperty Id -YProperty CPU -ErrorAction SilentlyContinue
$processes | Add-Scatter -Chart $chart -XProperty Id -YProperty Id -ErrorAction SilentlyContinue
Show-Chart -Chart $chart
$chart.Dialog.Join()
}
It "Draws a Line Chart" {
$chart = New-Chart
$chart.Title = 'Get-Process (line)'
$chart.XAxisLabel = 'Process ID'
$chart.YAxisLabel = 'CPU'
Get-Process | Add-Line -Chart $chart -XProperty Id -YProperty CPU -Color Red -ErrorAction SilentlyContinue
Show-Chart -Chart $chart
$chart.Dialog.Join()
}
It "Draws a Bar Chart" {
$chart = New-Chart
$chart.Title = 'Get-Process (bar)'
$chart.XAxisLabel = 'Process ID'
$chart.YAxisLabel = 'CPU'
Get-Process -PipelineVariable process |
Where-Object CPU -LT 30 |
ForEach-Object { # ensures CPU is minimum of 1
switch ($process) {
{$_.CPU -LT 1} {
$p = [PSCustomObject]@{
Id = $_.Id
CPU = 1
}
Write-Output $p
}
default {
Write-Output $_
}
}
} |
Add-Bar -Chart $chart -XProperty Id -YProperty CPU -Color Red -ErrorAction SilentlyContinue
$chart.YMin = 0
Show-Chart -Chart $chart
$chart.Dialog.Join()
}
}