PowerShell/test/powershell/Language/Scripting/Scripting.Followup.Tests.ps1
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00

33 lines
1.4 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Scripting.Followup.Tests" -Tags "CI" {
It "'[void](New-Item) | <Cmdlet>' should work and behave like passing AutomationNull to the pipe" {
try {
$testFile = Join-Path $TestDrive (New-Guid)
[void](New-Item $testFile -ItemType File) | ForEach-Object { "YES" } | Should Be $null
## file should be created
$testFile | Should Exist
} finally {
Remove-Item $testFile -Force -ErrorAction SilentlyContinue
}
}
## cast non-void method call to [void]
It "'[void]`$arraylist.Add(1) | <Cmdlet>' should work and behave like passing AutomationNull to the pipe" {
$arraylist = [System.Collections.ArrayList]::new()
[void]$arraylist.Add(1) | ForEach-Object { "YES" } | Should Be $null
## $arraylist.Add(1) should be executed
$arraylist.Count | Should Be 1
$arraylist[0] | Should Be 1
}
## void method call
It "'`$arraylist2.Clear() | <Cmdlet>' should work and behave like passing AutomationNull to the pipe" {
$arraylist = [System.Collections.ArrayList]::new()
$arraylist.Add(1) > $null
$arraylist.Clear() | ForEach-Object { "YES" } | Should Be $null
## $arraylist.Clear() should be executed
$arraylist.Count | Should Be 0
}
}