forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerShellGithubDev.Tests.ps1
More file actions
162 lines (145 loc) · 6.32 KB
/
Copy pathPowerShellGithubDev.Tests.ps1
File metadata and controls
162 lines (145 loc) · 6.32 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
$originalPSModulePath = $env:PSModulePath
try
{
# load all modules only from $env:DEVPATH !!!
$env:PSModulePath = "$($env:DEVPATH)\Modules"
# this Describe makes sure we build all the dlls we want and load them from the right place
Describe 'build.psm1 and powershell.exe' {
Context '$env:DEVPATH assemblies loading' {
It 'has $env:DEVPATH set' {
$env:DEVPATH | Should Not Be $null
}
It 'loads System.Management.Automation.dll' {
[psobject].Assembly.Location | Should Be (
Join-Path $env:DEVPATH System.Management.Automation.dll)
}
It 'loads Microsoft.PowerShell.Commands.Management.dll' {
[Microsoft.PowerShell.Commands.GetChildItemCommand].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.PowerShell.Commands.Management.dll)
}
It 'loads Microsoft.PowerShell.Commands.Utility.dll' {
[Microsoft.PowerShell.Commands.UtilityResources].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.PowerShell.Commands.Utility.dll)
}
It 'loads Microsoft.PowerShell.ConsoleHost.dll' {
[Microsoft.PowerShell.ConsoleShell].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.PowerShell.ConsoleHost.dll)
}
It 'loads Microsoft.PowerShell.Security.dll' {
[Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.PowerShell.Security.dll)
}
It 'loads Microsoft.PowerShell.Workflow.ServiceCore.dll' {
workflow wfTest { Split-Path $pwd }
wfTest | Should Not Be $null ## Also trigger the loading of ServiceCore.dll
[Microsoft.PowerShell.Workflow.PSWorkflowJob].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.PowerShell.Workflow.ServiceCore.dll)
}
}
}
# this Describe makes sure we binplace all the files, like psd1, psm1, ps1xml and load usable modules from them
Describe 'Modules for the package' {
Context '$env:DEVPATH Modules loading' {
It 'loads Microsoft.PowerShell.LocalAccounts' {
try
{
Import-Module Microsoft.PowerShell.LocalAccounts -ErrorAction Stop
Get-LocalUser | Should Not Be $null
}
finally
{
Remove-Module -ErrorAction SilentlyContinue Microsoft.PowerShell.LocalAccounts
}
}
It 'loads Microsoft.PowerShell.Archive' {
try
{
Import-Module Microsoft.PowerShell.LocalAccounts -ErrorAction Stop
Set-Content -Path TestDrive:\1.txt -Value ''
Compress-Archive -Path TestDrive:\1.txt -DestinationPath TestDrive:\1.zip
Get-ChildItem -Path TestDrive:\1.zip | Should Not Be $null
}
finally
{
Remove-Module -ErrorAction SilentlyContinue Microsoft.PowerShell.Archive
}
}
It 'loads PsScheduledJob' {
try
{
Import-Module PsScheduledJob -ErrorAction Stop
New-ScheduledJobOption | Should Not Be $null
}
finally
{
Remove-Module -ErrorAction SilentlyContinue PsScheduledJob
}
}
It 'loads PSWorkflowUtility' {
try
{
Import-Module PSWorkflowUtility -ErrorAction Stop
Invoke-AsWorkflow -Expression { 'foo' } | Should Be 'foo'
}
finally
{
Remove-Module -ErrorAction SilentlyContinue PSWorkflowUtility
}
}
It 'loads PSWorkflow' {
try
{
Import-Module PSWorkflow -ErrorAction Stop
New-PSWorkflowExecutionOption | Should Not Be $null
}
finally
{
Remove-Module -ErrorAction SilentlyContinue PSWorkflow
}
}
It 'loads CimCmdlets' {
try
{
Import-Module CimCmdlets -ErrorAction Stop
Get-CimClass -ClassName CIM_Error | Should Not Be $null
[Microsoft.Management.Infrastructure.CimCmdlets.AsyncResultType].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.Management.Infrastructure.CimCmdlets.dll)
}
finally
{
Remove-Module -ErrorAction SilentlyContinue CimCmdlets
}
}
It 'loads Microsoft.WSMan.Management' {
try
{
Import-Module Microsoft.WSMan.Management -ErrorAction Stop
Test-WSMan | Should Not Be $null
[Microsoft.WSMan.Management.TestWSManCommand].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.WSMan.Management.dll)
}
finally
{
Remove-Module -ErrorAction SilentlyContinue Microsoft.WSMan.Management
}
}
It 'loads Microsoft.PowerShell.Diagnostics' {
try
{
Import-Module Microsoft.PowerShell.Diagnostics -ErrorAction Stop
Get-WinEvent -LogName System -MaxEvents 1 | Should Not Be $null
[Microsoft.PowerShell.Commands.GetWinEventCommand].Assembly.Location | Should Be (
Join-Path $env:DEVPATH Microsoft.PowerShell.Commands.Diagnostics.dll)
}
finally
{
Remove-Module -ErrorAction SilentlyContinue Microsoft.PowerShell.Diagnostics
}
}
}
}
}
finally
{
$env:PSModulePath = $originalPSModulePath
}