Files
PowerShell/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1
T
Travis Plunk 8f37c920ef Blacklist System.Windows.Forms form loaded to prevent a crash (#6822)
Blacklist `System.Windows.Forms` (`WinForms`) from being loaded to prevent a crash
2018-05-07 16:38:27 -07:00

35 lines
1.0 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Assembly::LoadWithPartialName Validation Test" -Tags "CI" {
$defaultErrorId = 'FileLoadException'
$testcases = @(
# verify winforms is blocked
@{
Name = 'system.windows.forms'
ErrorId = $defaultErrorId
}
# Verify alternative casing is blocked
@{
Name = 'System.Windows.Forms'
ErrorId = $defaultErrorId
}
)
# All existing cases should fail on all platforms either because it doesn't exist or
# because the assembly is blacklisted
It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: <Name>" -TestCases $testcases {
param(
[Parameter(Mandatory)]
[string]
$Name,
[Parameter(Mandatory)]
[string]
$ErrorId
)
{[System.Reflection.Assembly]::LoadWithPartialName($Name)} | Should -Throw -ErrorId $ErrorId
}
}