mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Convert ShouldBeErrorId to Should -Throw -ErrorId in PowerShell tests.
Get rid of try { } catch { } formula to assert that errors were thrown.
Small fixes in tests to obey the new Pester -Parameter syntax.
27 lines
744 B
PowerShell
27 lines
744 B
PowerShell
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
Describe "Attribute tests" -Tags "CI" {
|
|
BeforeEach {
|
|
Remove-Item $testdrive/test.ps1 -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
It "<attribute> attribute returns argument error if empty" -TestCases @(
|
|
@{Attribute="HelpMessage"},
|
|
@{Attribute="HelpMessageBaseName"},
|
|
@{Attribute="HelpMessageResourceId"}
|
|
) {
|
|
param($attribute)
|
|
|
|
$script = @"
|
|
[CmdletBinding()]
|
|
Param (
|
|
[Parameter($attribute="")]
|
|
[String]`$Parameter1
|
|
)
|
|
Write-Output "Hello"
|
|
"@
|
|
New-Item -Path $testdrive/test.ps1 -Value $script -ItemType File
|
|
{ & $testdrive/test.ps1 } | Should -Throw -ErrorId "Argument"
|
|
}
|
|
}
|