forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScripting.Classes.MiscOps.Tests.ps1
More file actions
46 lines (42 loc) · 1.24 KB
/
Copy pathScripting.Classes.MiscOps.Tests.ps1
File metadata and controls
46 lines (42 loc) · 1.24 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
Describe 'Misc Test' -Tags "CI" {
Context 'Where' {
class C1 {
[int[]] $Wheels = @(1,2,3);
[string] Foo() {
return (1..10).Where({ $PSItem -in $this.Wheels; }) -join ';'
}
[string] Bar()
{
return (1..10 | Where { $PSItem -in $this.Wheels; }) -join ';'
}
}
It 'Invoke Where' {
[C1]::new().Foo() | should be "1;2;3"
}
It 'Pipe to where' {
[C1]::new().Bar() | should be "1;2;3"
}
}
Context 'ForEach' {
class C1 {
[int[]] $Wheels = @(1,2,3);
[string] Foo() {
$ret=""
Foreach($PSItem in $this.Wheels) { $ret +="$PSItem;"}
return $ret
}
[string] Bar()
{
$ret = ""
$this.Wheels | foreach { $ret += "$_;" }
return $ret
}
}
It 'Invoke Foreach' {
[C1]::new().Foo() | should be "1;2;3;"
}
It 'Pipe to Foreach' {
[C1]::new().Bar() | should be "1;2;3;"
}
}
}