2016-07-25 23:01:41 +02:00
|
|
|
Describe 'Misc Test' -Tags "CI" {
|
2016-07-19 22:52:03 +02:00
|
|
|
|
|
|
|
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;"
|
|
|
|
}
|
|
|
|
}
|
2016-07-25 23:01:41 +02:00
|
|
|
}
|