-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTest.ps1
206 lines (161 loc) · 5.72 KB
/
Test.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
param(
[switch] $ImportPackage,
[Alias("NewThreadController")]
[switch] $NewDispatchThread,
[string] $Root = (& {
If( $PSScriptRoot ){
$PSScriptRoot
} Else {
Resolve-Path .
}
})
)
If( -not $ImportPackage -and -not $NewDispatchThread ){
$ImportPackage = $true
$NewDispatchThread = $true
}
$global:__testing = $true
If( $ImportPackage ){
Import-Module "PackageManagement"
}
$VerbosePreference = "Continue"
If( $ImportPackage ){
Write-Host "[Import-Package:Testing] Begin Testing?"
pause;
Measure-Command {
Import-Module "$Root\Import-Package\"
}
Write-Host "[Import-Package:Testing] Initialized. Continue Testing?"
pause;
# --- Basic Testing ---
Measure-Command {
Write-Host "[Import-Package:Testing] Testing with Avalonia.Desktop and Microsoft.ClearScript"
Import-Package Avalonia.Desktop -Offline
Import-Package Microsoft.ClearScript -Offline
}
Write-Host "[Import-Package:Testing] Avalonia.Desktop and Microsoft.ClearScript should be loaded. Continue Testing?"
pause;
# --- Path Parameter Testing ---
Write-Host "[Import-Package:Testing] Testing the Unmanaged Parameterset"
$unmanaged = @{}
# Has no dependencies
$unmanaged.Simple = Get-Package NewtonSoft.json
# Has 1 dependency
$unmanaged.Complex = Get-Package NLua
$unmanaged.Simple = $unmanaged.Simple.Source
$unmanaged.Complex = $unmanaged.Complex.Source
Measure-Command { Import-Package -Path $unmanaged.Simple }
Write-Host "[Import-Package:Testing] Testing the Unmanaged Parameterset with a simplistic package is complete. Continue Testing?"
pause;
Measure-Command { Import-Package -Path $unmanaged.Complex }
Write-Host "[Import-Package:Testing] Testing the Unmanaged Parameterset with a complex package is complete. Continue Testing?"
pause;
Measure-Command { Import-Package NLua -SkipDependencies }
Write-Host "[Import-Package:Testing] Testing the -SkipDependencies switch is complete. Continue Testing?"
pause;
Measure-Command { Import-Package IronRuby.Libraries }
Write-Host "[Import-Package:Testing] Testing the Semver2 packages (and the package cache) is complete. Continue Testing?"
pause;
@(
[Microsoft.ClearScript.V8.V8ScriptEngine]
[Avalonia.Application]
[Newtonsoft.Json.JsonConverter]
[NLua.Lua]
[IronRuby.Ruby]
) | Format-Table
Write-Host
Write-Host "System Runtime ID:" (Get-Runtime)
}
If( $NewDispatchThread ){
Write-Host "[New-ThreadController:Testing] Begin Testing?"
pause;
Import-Module "$Root\New-ThreadController\"
# Should dump a warning followed by an error
Write-Host
Write-Host "--- New-ThreadController:Avalonia"
Update-DispatcherFactory ([Avalonia.Threading.Dispatcher])
# --- ThreadExtensions ---
Write-Host
Write-Host "--- New-ThreadController:ThreadExtensions"
Update-DispatcherFactory ([ThreadExtensions.Dispatcher])
$t1 = New-ThreadController
$t1.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - ThreadExtensions:Un-named"
}).
Invoke({ Write-Host "done - ThreadExtensions:Un-named" }, $true) | Out-Null
Write-Host
Try{
$t2 = New-ThreadController -Name "Tester"
$t2.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - ThreadExtensions:Named"
}).
Invoke({ Write-Host "done - ThreadExtensions:Named" }, $true) | Out-Null
} Catch {
Write-Host "Caught error: $_"
}
Write-Host
Try{
(Async {
Write-Host "Thread:" $ThreadName
Write-Host "self-disposed test - ThreadExtensions:Async"
}).
Invoke({ Write-Host "done - ThreadExtensions:Async" }, $true) | Out-Null
} Catch {
Write-Host "Caught error: $_"
}
Write-Host
$anon1 = New-ThreadController -Name "Anonymous"
(Async {
Write-Host "Thread:" $ThreadName
Write-Host "test - ThreadExtensions:Anon"
} -Thread $anon1).
Invoke({ Write-Host "done - ThreadExtensions:Anon" }, $true) | Out-Null
Write-Host
# --- WPF ---
If( [System.Windows.Threading.Dispatcher] ){
Write-Host
Write-Host "--- New-ThreadControllerd:WPF"
Update-DispatcherFactory ([System.Windows.Threading.Dispatcher])
$t3 = New-ThreadController
$t3.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - WPF:Un-named"
}).
Invoke({ Write-Host "done - WPF:Un-named" }, $true) | Out-Null
Write-Host
Try{
$t4 = New-ThreadController -Name "Tester"
$t4.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - WPF:Named"
}).
Invoke({ Write-Host "done - WPF:Named" }, $true) | Out-Null
} Catch {
Write-Host "Caught error: $_"
}
Write-Host
Try {
(Async {
Write-Host "Thread:" $ThreadName
Write-Host "self-disposed test - WPF:Async"
}).
Invoke({ Write-Host "done - WPF:Anon" }, $true) | Out-Null
} Catch {
Write-Host "Caught error: $_"
}
Write-Host
$anon2 = New-ThreadController -Name "Anonymous"
(Async {
Write-Host "Thread:" $ThreadName
Write-Host "test - WPF:Anon"
} -Thread $anon2).
Invoke({ Write-Host "done - WPF:Anon" }, $true) | Out-Null
Write-Host
}
Write-Host
Write-Host "Threads:"
$Threads = Get-Threads
$Threads
}